Terser is a powerful JavaScript parser, mangler, and compressor toolkit designed for modern ECMAScript (ES6+). It currently stands at version 5.46.1 and is under active development, serving as the maintained successor to the now-abandoned `uglify-es` project and `uglify-js` (which lacks ES6+ support). Terser largely retains API and CLI compatibility with its predecessors, making it a familiar choice for developers. Key differentiators include its robust support for modern JavaScript syntax and ongoing maintenance, addressing the limitations of older minifiers. While `terser` previously offered beautification features, these are being removed in favor of dedicated tools like Prettier. The project recommends using it in conjunction with bundlers like RollupJS for optimal output size.
npm install terserVerified import paths — ran on the pinned version, not inferred.
Demonstrates how to programmatically minify a JavaScript string using `terser`, including compression and mangling options for ES2020 syntax.
Replace `uglify-es` or `uglify-js` with `terser` in `package.json` and update build scripts accordingly.
Remove any `beautify` related options from `terser` configuration. Integrate `prettier` into your development workflow for code formatting.
Command line usage: `terser --compress --mangle -- input.js` instead of `terser --compress --mangle input.js`.
Upgrade your Node.js environment to version 10 or newer. Check your `package.json` `engines` field for compatibility.
Ensure `terser` is installed and configured as your JavaScript minifier in your build pipeline, and that `uglify-js` is not accidentally being used.
For ESM: `import { minify } from 'terser';`. For CommonJS: `const { minify } = require('terser');`Remove any `beautify` options from your `terser` configuration. Use a dedicated code formatter like Prettier instead for beautification.
No dependency data recorded yet.