UglifyJS is a JavaScript minifying tool, which runs on NodeJS. Compared with other popular JavaScript minifiers, such as YUI Compressor and Google Closure, a remarkable advantage of using UglifyJS is that it’s available as a native command. To utilize UglifyJS, we need to install NodeJS first and then the UglifyJS module.

Here is the guideline on installing NodeJS https://github.com/joyent/node/wiki/Installation. After successful installation, node server starts running.

Then, install UglifyJS module https://github.com/mishoo/UglifyJS#Install on the node server. After adding the UglifyJS path into PATH, we are able to use it via command prompt:

$ uglifyjs -nc -o [output js] [input js]

Extremely easy, isn’t it? Following is a small test comparing the compressing efficiency of different minifiers:

Original Uglify Closure YUI Compressor
size 193.5 KB 62.3 KB 61.3 KB 64.4 KB