Global definitions

This is a feature you can use in order to conditionally drop code. For
example if you pass:

global_defs: {
DEBUG: false
}

the compressor will assume that's a constant defintion and will discard
code like this as being unreachable:

if (DEBUG) {
...
}

This is useful in order to discard stuff that you need only in the
development version from production builds.

In previous version of UglifyJS you had to actually pass an AST for such
definitions, but in version 2 it's no longer the case—just pass the
JavaScript constants that you want your global definitions to evaluate to.

Latest blog entries tagged "uglifyjs"

UglifyJS 2 — online demo

Note that this is only tested with Chrome and Firefox. Should work
with Safari as well, but most probably not with Opera or IE.

Paste your code in the left box. Click “Uglify!” to get compressed
output on the right. The left-side will turn into
the Ymacs
editor. At this point if you click any token in the minified area,
the editor on the left will move to the original location of that
minified token.

Tick the “As I type” checkbox to turn on minification
on-the-fly.

When the compressor warns, you'll get a flashing button in the
toolbar. Click on it to display the warnings (temporarily covers
the minified area). Click a warning in the list to go to that
position in the source. If you have "on-the-fly" and fix warnings,
the list will update automatically.

You can enable/disable the compressor, mangler and beautifier. For
additional control check the buttons on the right
(“Compressor...” and “Codegen...”). Those
options are saved in localStorage, they will be remembered the next
time you visit this page.