Download UglifyJS 2 Browser

Where can I download the UglifyJS 2 browser assembly ? I had a problem creating it.

I installed uglify-jswith npm number. I just don’t know where to run the command uglifyjs --selfto create the browser version. I keep getting this error:

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

Also in the browser build, I'm not sure how to minimize the javascript line of code. I realized what I can do UglifyJS.parse(scriptEl.innerHTML)to create a tree of JS parsing objects, then I can use the method .print_to_string();to convert it back to a string, but without spaces, but I can’t figure out which method to use to completely minimize it, including variable renaming etc.

+4
source share
2 answers

Go to http://lisperator.net/uglifyjs/

Once you have installed it for NodeJS, UglifyJS2 provides a quick way to create a browser yourself:

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

. .

:

. , uglifyjs , , . npm -g install uglify-js , .

+3

, uglifyjs, . :

npm install -g uglify-js

. . "-g", , . "-g" node, . uglifyjs --self .

, :

var result = scripts.join("\n\n");  # concat
result = UglifyJS.minify(result, {fromString: true});
console.log(result.code);

, .

+1

All Articles