How JavaScript minification works
This tool uses Terser, the minifier behind most modern build tools. It removes comments and whitespace, renames local variables to short names (totalPrice becomes t) and, with compress on, rewrites code into shorter equivalents and removes code that can never run.
Typical savings
| Option | What it does | Typical saving |
|---|---|---|
| Whitespace and comments only | Safest | 20–30% |
| + Shorter names (mangle) | Renames local variables | 40–50% |
| + Compress | Rewrites and removes dead code | 50–60%+ |
Is it ES module code?
Turn on “ES module” for files that use import and export. Module code is always in strict mode, which lets Terser shorten even top-level names safely.
Things to watch
- Keep the original file for editing; minified code is not meant to be read.
- If other scripts call your functions by name, check that those global names still work after minifying.
- Syntax errors stop the minifier; the message shows the line to fix.
Shrink your styles too with the CSS Minifier. Your code is processed in your browser and never uploaded.