Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to run UglifyJS2 without Node.JS

Anyway to run UglifyJS2 without node.js? Say I would like to run it in a JVM process using JavaScript script engine. How to do that?

like image 245
Gelin Luo Avatar asked Feb 08 '13 01:02

Gelin Luo


People also ask

Can JS run without node?

TLDR; Node. js has become so integral in the building and executing of (javascript based) web applications that it is not very difficult, if not impossible, to continue development without Node. js.

What is Uglify JS?

Uglify JS is a JavaScript library for minifying JavaScript files. To 'uglify' a JavaScript file is to minify it using Uglify. Uglification improves performance while reducing readability. Encryption: This is the process of translating data, called plain data, into encoded data.


1 Answers

I saw mishoo answered you https://github.com/mishoo/UglifyJS2/issues/122

Two possible ways:

  • run uglifyjs --self to get a build of UglifyJS that you can load in a browser (or in any JS environment) and you can use the API described here.

  • load in your environment all files in the lib/ directory (load utils.js and ast.js first, the others can come in whatever order). If you do this, everything will be global—you can use the same API but there's no need to prefix stuff with UglifyJS..

Also you might want to look at tools/node.js to see how we load it in Node (as we're not using the standard require).

like image 157
corbacho Avatar answered Sep 21 '22 18:09

corbacho