What JavaScript minification does to your code
Basic minification removes comments and whitespace — the same operations as CSS minification. But JS minifiers can go further because they understand code structure, not just text.
Variable renaming is the most impactful transformation. Long, descriptive names like calculateShippingCost become single-letter names like a. This doesn't change what the code does but can reduce file size substantially in a function-heavy codebase.
Dead code elimination removes code that is never executed — unreachable branches, unused functions, and console.log statements flagged for removal. This requires the minifier to understand the code's control flow.
- Removes comments and whitespace
- Shortens variable and function names
- Removes dead code and unreachable branches
- Replaces string literals with shorter equivalents where safe
- Inlines small functions
- Simplifies constant expressions (1 + 2 → 3)
Minification vs bundling vs tree-shaking
These are three different optimizations that often happen together in a build pipeline. Bundling combines multiple JS files into one to reduce HTTP requests. Tree-shaking removes exported code that is never imported or used anywhere in the project. Minification compresses the resulting bundle.
All three together produce the smallest possible output. Modern bundlers like Vite, webpack, and Rollup apply all three automatically in production mode. Esbuild and SWC are newer, significantly faster minifiers that are becoming standard in build tools.
For a quick one-off minification task — a standalone script, a bookmarklet, a widget you're copying into a CMS — an online minifier is faster than setting up a build pipeline.
How to minify JavaScript with the online tool
The Irreva JS Minifier accepts JavaScript code, minifies it in the browser, and gives you the output to copy. It handles modern JavaScript including ES6+ features: arrow functions, template literals, destructuring, spread operators, and async/await.
Paste your code, copy the minified output, and use it in your project. No server required, no account, no rate limits. The tool runs entirely in your browser using a JavaScript parsing library.
For source maps — which allow browser devtools to show you the original unminified code for debugging — you'll need a proper build tool like esbuild or webpack. Source map generation isn't available in the online minifier.
When to minify and when not to
Always minify code that goes to production. Don't minify code you're actively developing, debugging, or that other developers need to read. The minified version is for browsers; the readable version is for humans.
If you're publishing an open-source library, publish both the minified and the unminified version. Many package managers and CDNs expect a .min.js convention for the minified build.
Some developers also add a copy of the source to the production site via source maps, so that error monitoring tools like Sentry can map minified stack traces back to the original code.
