This little tool offers to build UglifyJS for a web browser by wrapping the actual code into closures and expose an easy to use API
Just clone, init the submodules and run the build.js
module with node
eg:
git clone --recursive git://github.com/Trenker/Browser-UglifyJS.git browser-uglifyjs
cd browser-uglifyjs
node build.js
The result is written into the build folder
Simpy add this HTML
<script type="text/javascript" src="uglifyjs.1.2.5.js"></script>
Now you can uglify some code like this:
var rawCode = document.forms[0].rawCode.value;
var minCode = uglify(rawCode);
document.forms[0].minCode.value = minCode;
By default, the wrapper offers the possiblity to be run as a Worker
eg.:
var myWorker = new Worker('uglifyjs.1.2.5.js');
myWorker.onmessage = function(minCode) {
document.forms[0].minCode.value = minCode
}
document.forms[0].doUglifyButton.value.onclick = function() {
myWorker.postMessage(document.forms[0].rawCode.value);
};
All credits for this tool go to Mihai Bazon. He created uglifyJS, I only did the wrapper.
License for both UglifyJS and Browser - UglifyJS is the BSD License. See the LICENSE.md file for details