Scroll to navigation

UGLIFYJS(1) General Commands Manual UGLIFYJS(1)

NAME

uglifyjs - a JavaScript parser/compressor/beautifier
 

SYNOPSIS

uglifyjs [options] [input_file]
 

DESCRIPTION

This package implements a general-purpose JavaScript parser/compressor/beautifier toolkit.
 

OPTIONS

-b, --beautify
 
Output indented code; when passed, additional options control the beautifier.
 
 
-i number-of-spaces, --indent number-of-spaces
 
Indentation level.
 
 
-q, --quote-keys
 
Quote keys in literal objects (by default, only keys that cannot be identifier names will be quotes).
 
 
-mt, --mangle-toplevel
 
Mangle names in the toplevel scope too (by default we don’t do this).
 
 
-nm, --no-mangle
 
Don’t mangle variable names.
 
 
-nmf, --no-mangle-functions
 
In case you want to mangle variable names, but not touch function names.
 
 
-ns, --no-squeeze
 
Don’t call ast_squeeze() (which does various optimizations that result in smaller, less readable code).
 
 
--no-seqs
 
When ast_squeeze() is called (thus, unless you pass --no-squeeze) it will reduce consecutive statements in blocks into a sequence. For example, "a = 10; b = 20; foo();" will be written as "a=10,b=20,foo();". In various occasions, this allows us to discard the block brackets (since the block becomes a single statement). This is ON by default because it seems safe and saves a few hundred bytes on some libs that I tested it on, but pass --no-seqs to disable it.
 
 
--no-dead-code
 
By default, UglifyJS will remove code that is obviously unreachable (code that follows a return, throw, break or continue statement and is not a function/variable declaration). Pass this option to disable this optimization.
 
 
-nc, --no-copyright
 
By default, uglifyjs will keep the initial comment tokens in the generated code (assumed to be copyright information etc.). If you pass this it will discard it.
 
 
-o filename, --output filename
 
Put the result in filename. If this isn’t given, the result goes to standard output (or see next one).
 
 
--overwrite
 
If the code is read from a file (not from STDIN) and you pass --overwrite then the output will be written in the same file.
 
 
-v, --verbose
 
Output some notes on STDERR (for now just how long each operation takes).
 
 
--ast
 
Pass this if you want to get the Abstract Syntax Tree instead of JavaScript as output. Useful for debugging or learning more about the internals.
 
 
--unsafe
 
Enable other additional optimizations that are known to be unsafe in some contrived situations, but could still be generally useful. For now only this: foo.toString() ==> foo+""
 
 
--max-line-len value
 
(default 32K characters) — Add a newline after around 32K characters. I’ve seen both FF and Chrome croak when all the code was on a single line of around 670K. Pass --max-line-len 0 to disable this safety feature.
 
 
--reserved-names name1,$name2,name3
 
Some libraries rely on certain names to be used, as pointed out in issue #92 and #81, so this option allow you to exclude such names from the mangler. For example, to keep names require and $super intact you’d specify --reserved-names "require,$super"
 
 
-c, --consolidate-primitive-values
 
Consolidates null, Boolean, and String values. Known as aliasing in the Closure Compiler. Worsens the data compression ratio of gzip.
 
 
--ascii
 
Pass this argument to encode non-ASCII characters as XXXX sequences. By default UglifyJS won’t bother to do it and will output Unicode characters instead. (the output is always encoded in UTF8, but if you pass this option you’ll only get ASCII).
 
 
--inline-script
 
when you want to include the output literally in an HTML <script> tag you can use this option to prevent </script from showing up in the output.
 
--lift-vars
 
When you pass this, UglifyJS will apply the following transformations (see the notes in API, ast_lift_variables):
put all var declarations at the start of the scope
make sure a variable is declared only once
discard unused function arguments
discard unused inner (named) functions
finally, try to merge assignments into that one var declaration, if possible.
 
 

BUGS

The bug tracker can be reached by visiting the website https://github.com/mishoo/UglifyJS/issues
 
Before sending a bug report, please verify that you have the latest version of UglifyJS. Many bugs (major and minor) are fixed at each release, and if yours is out of date, the problem may already have been solved.
 

ADDITIONAL INFORMATION

For further information, visit the website https://github.com/mishoo/UglifyJS