Home
Docs
GitHub
Pricing
Blog
Log In

Run Sandworm Audit for your App

Get started
Hold on, we're currently generating a fresh version of this report

terser 5.27.0

JavaScript parser, mangler/compressor and beautifier toolkit for ES6+
Package summary
Share
0
issues
0
licenses
Package created
12 May 2018
Version published
17 Jan 2024
Maintainers
1
Total deps
0
Direct deps
0
License
BSD-2-Clause
Generating a report...
Hold on while we generate a fresh audit report for this package.

Frequently Asked Questions

What does terser do?

Terser is a JavaScript parser, mangler, compressor, and beautifier toolkit targeting ECMAScript 6 and beyond. It works to reduce the size of your JavaScript files by removing redundant or irrelevant data without affecting its functioning. This process is known as compacting or minifying. Terser mangles and compresses your files to remove spaces, indentation, newlines, and comments. In addition, it shortens the names of your variables and parameters to single-letters. Terser is essentially a fork of uglify-es that retains API and CLI compatibility with uglify-es and uglify-js@3.

How do you use terser?

You can use Terser via the command line or programmatically in your application.

To install it for command-line usage, you should run the following command:

npm install terser -g

For programmatic usage within your application, the recommended installation command is:

npm install terser

In your JavaScript code, you can then import Terser and use the minify function to reduce your code size. For instance:

const { minify } = require("terser");

async function run() {
 let code = "function add(first, second) { return first + second; }";
 let result = await minify(code);
 console.log(result.code);  // minified output
}

run();

Please note that the minify function is asynchronous and must be awaited or chained with .then() and .catch().

Where are the terser docs?

The Terser documentation can be found in the README file on its GitHub repository at https://github.com/terser/terser. The available options and API for using Terser are outlined and explained in detail in the README. A link to each section detailing how to use the various options and configurations available in Terser can be found in the Table of Contents.