Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

example.js and example.min.js do not match #688

Open
samcov opened this issue Nov 4, 2021 · 1 comment
Open

example.js and example.min.js do not match #688

samcov opened this issue Nov 4, 2021 · 1 comment

Comments

@samcov
Copy link

samcov commented Nov 4, 2021

The example.js and example.min.js do not match.

The min version is almost 8 times as large, and the code is different.

@LuHC409
Copy link

LuHC409 commented Apr 2, 2025

Why example.min.js Is Much Larger and Looks Different from example.js

✅ 1. Different Purposes

  • example.js is a demo script, meant to be read and modified during development.
  • example.min.js is a browser-ready bundle generated using tools like Browserify or Webpack.

✅ 2. Contents of Each File

File Purpose Contains
example.js Development/demo use Only the user-defined code (e.g. dragula usage)
example.min.js Browser-executable production code example.js + all dependencies + module loader

✅ 3. Why example.min.js Is Larger

  • It bundles all dependencies: crossvent, dragula, custom-event, etc.
  • It includes a module system shim to make require() work in browsers.
  • It might also contain source maps or debug info encoded in base64.

✅ 4. Why the Code Looks Different

  • example.js uses require() (Node-style modules).
  • example.min.js wraps everything in an IIFE (Immediately Invoked Function Expression) to simulate a module system.
  • Minification removes formatting and renames variables to reduce file size.
  • Despite the different structure, example.min.js includes the same logic as example.js, plus all required modules.

🔍 Example:

// example.js
var crossvent = require('crossvent');
dragula([...]);
// example.min.js (simplified structure)
(function e(t,n,r){
  // Module loader...
  // crossvent definition...
  // dragula logic...
  // your example.js logic...
})(...)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants