Skip to content

Build UglifyJS with a wrapper that enables using it in a web browser

License

Notifications You must be signed in to change notification settings

garfieldius/Browser-UglifyJS

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Browser UglifyJS

About

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

Built it

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

Useage in a browser - Normal

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;

Usage in a browser - Workers

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);
};

Credits and License

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

About

Build UglifyJS with a wrapper that enables using it in a web browser

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published