Developer guide
How to use a JavaScript minifier safely
JavaScript minification prints parsed code compactly, but module mode, modern syntax, comments, source maps, and regression testing all affect a safe release.
Open the JavaScript MinifierWhat JavaScript minification does
A minifier removes formatting and ordinary comments, then prints a smaller program. Some tools also compress expressions or rename variables, which can increase savings but requires more careful configuration.
The ToolPixels minifier uses Terser with compression and name mangling disabled. It compacts syntax without running the submitted code.
How to use a JavaScript minifier
- Start from tested source and keep it in version control.
- Choose ES module mode for
import,export, or top-levelawait. - Paste JavaScript or open a UTF-8 file.
- Select Minify JavaScript.
- Test the compact output in the target runtime before deployment.
A basic minification example
Input
function add(a, b) {
return a + b;
}
Output
function add(a,b){return a+b}
The function and parameter names remain because name mangling is disabled.
Script mode and module mode
| Mode | Use it for |
|---|---|
| Script | Classic scripts without module-only syntax |
| ES module | Imports, exports, and top-level await |
Selecting the wrong mode can cause valid source to fail parsing. JSX and TypeScript must be compiled before using this minifier.
Release checks
- License and preservation comments should remain when required.
- Source-map comments are removed and no replacement map is generated.
- Minification does not bundle modules or transpile syntax.
- Run automated tests against the exact compact artifact.
- Serve JavaScript with Brotli or gzip for additional network savings.
Use the browser tool
Compact tested JavaScript locally without compression or name mangling, with an explicit ES module option.