Minify JavaScript with terser: removes whitespace and comments and shortens local names.
The tool uses Terser, a JavaScript parser and minifier used inside many build tools. Because it understands the code rather than just deleting spaces, it doesn't make the classic mistakes of simple minifiers: code without semicolons keeps working, a + +b doesn't turn into a++b, and text inside strings and template literals is never changed.
It removes whitespace and comments, simplifies some expressions, and renames local variables and function parameters to short names. Global names and properties are left alone, so code that other scripts call still works. Comments marked /*! ... */ or containing @license are kept.
Keep your original file; minified code is hard to read and edit. Test the minified script once in your page. Terser is loaded only when you click Minify, so the page itself stays light. It supports modern JavaScript; TypeScript and JSX need compiling to plain JavaScript first.
Terser is designed not to change behaviour. Code that relies on function names at runtime (fn.name) can be affected by renaming, so test before publishing.
Partly, by shortening local names, but minified code can still be reformatted and read. It isn't protection.
No. Compile them to plain JavaScript first.
No. Terser runs in your browser.
OneClickly is a set of 119 free tools for PDFs, images, text, everyday math and code. They run in your browser, so the files and text you work with stay on your device.