Home

UglifyJS2

UglifyJS2 is a JavaScript code minifier and compressor that is part of the UglifyJS project. It processes JavaScript source code to remove whitespace, shorten identifiers, and apply various optimizations in order to reduce file size for distribution. The tool comprises a compressor, a mangler, and an AST-based pipeline for parsing, transforming, and code generation.

UglifyJS2 was developed as a rewrite of the original UglifyJS to provide improved support for newer JavaScript

Key features include dead code elimination, function inlining, constant folding, and scope-aware name mangling. It supports

Typical usage involves the command line, for example: uglifyjs input.js -o output.min.js -c -m. Programmatic use

syntax
(such
as
ES2015
and
beyond)
and
a
more
robust
set
of
optimization
features.
It
is
distributed
as
a
command-line
tool
and
can
also
be
used
programmatically
through
an
API,
making
it
suitable
for
integration
into
build
pipelines
and
task
runners.
generating
source
maps,
options
to
drop
console
statements,
and
configurable
compression
and
mangling
behavior.
UglifyJS2
can
also
handle
modules
and
offers
a
range
of
flags
to
tailor
output
for
compatibility
with
different
environments.
uses
the
UglifyJS.minify
function
to
perform
compression
and
mangling
with
a
configuration
object,
such
as
{
compress:
true,
mangle:
true
}.
In
recent
years,
development
for
UglifyJS2
has
been
complemented
by
forks
that
extend
ES2015+
support,
with
Terser
becoming
a
commonly
used
alternative
in
modern
toolchains.