Your JavaScript
Result
Runs in your browser with Terser and js-beautify. Your code is not uploaded.
What JavaScript minification does
This tool uses Terser, the minifier used by most modern build tools. It does three things:
- Removes comments, spaces and line breaks.
- Compresses code that can be written shorter with the same result, for example by joining statements and removing code that can never run.
- Mangles (optional) local variable and function parameter names to one or two letters. Global names and object properties are not renamed, so other scripts that use your code keep working.
Example: function greet(name){ var message = "Hello, "+name; console.log(message); return message; } becomes function greet(e){var o="Hello, "+e;return console.log(o),o}.
Comments that start with /*! or contain @license or @preserve are kept, because licences often require them.
Remove console calls
Tick Remove console.* calls to delete console.log() and similar debugging lines from the production file.
Beautify (format) mode
Beautify re-indents code so a minified or messy script becomes readable. It cannot restore the original variable names after mangling, but it makes the structure easy to follow.
Errors
If your code has a syntax error, Terser stops and shows the message (for example Unexpected token). Fix the error in your original file first. Modern syntax such as arrow functions, classes, async/await and optional chaining is supported.
Keep your original source file and only publish the minified copy; the minified version is very hard to edit.
Related: CSS Minifier · HTML Minifier · JSON Formatter · Regex Tester
