- is easy to use
- has a high compression rate
- Produce reliable end results (doesn’t mess up the code)
Node.js internals). It’s a lot faster than both YUI Compressor and Google Closure, it compresses better than YUI on all scripts I tested it on, and it’s safer than Closure (knows to deal with “eval” or “with”).
Other than whitespace removal, UglifyJS also does the following:
- changes local variable names (usually to single characters)
- joins consecutive var declarations
- avoids inserting any unneeded brackets, parens and semicolons
- optimizes IFs (removes “else” when it detects that it’s not needed, transforms IFs into the &&, || or ?/: operators when possible, etc.).
- removes quotes from keys in object literals, where possible
- resolves simple expressions when this leads to smaller code (1+3*4 ==> 13)
PS: Oh, it can “beautify” as well. 😉