Web_Designer Web_Designer - 1 year ago 138
Javascript Question

UglifyJS 2 browser build download

Where can I download the browser build of UglifyJS 2? I'm having trouble building it myself.

I installed

with npm. I just don't know where to run the
uglifyjs --self
command to build the browser version. I keep getting this error:

'uglifyjs' is not recognized as an internal or external command, operable program or batch file.

Also in the browser build, I'm not sure how to minify a string of javascript code. I figured out that I can do
to create an object tree of the parsed JS, then I can use the
method to convert it back to a string but without the whitespace, but I can't figure out what method to use to fully minify it including variable renaming and such.

Answer Source

Head over to http://lisperator.net/uglifyjs/

Once you installed it for NodeJS, UglifyJS2 provides a quick way to build itself for the browser:

uglifyjs --self -c -m -o ./tmp/uglifyjs.js

The command worked for me. Now, you can use it in your browser straight away.

For specifying the options for the methods, you should look at:

Note: the error you're getting when you run uglifyjs in your command-line seems like your terminal is not able to locate the installed file. Try to do a global install using npm -g install uglify-js or use the command from the directory where you installed it in.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download