What is the best JavaScript compression/obfuscation tool? [closed]
What kind of a tool would you recommend for JavaScript compression and/or obfuscation? A google search comes back with a lot of online tools, but I am not sure how to gauge their effectiveness/usefulness.
Is there a tool that you would recommend for this?
Thanks,
There are many tools that transform Javascript in something different. I currently classify these tools in the following objectives:
- Minify: make the code smaller by removing comments, renaming variables...
- Compress: Compress using non destructive compression of javascript
- Optimize: Make the code run faster (ex: Closure)
- Obfuscate: Protect the code
My order has some meaning behind it. Because generally the higher level includes all be features below.
So a good Javascript Obfuscator is able to minify, compress, optimize...
Many tools do some of these levels well individually. They can be combined making them more effective but my experience has shown that combining several such tools make it a nightmare to try and pin point a problem.
My suggestion for a good overall Javascript obfuscator would be to use jscrambler.com
For optimization and minification google closure (has sugested by aepheus) is a excellent solution.
Closure Complier: http://code.google.com/closure/compiler/
YUI Compressor: http://developer.yahoo.com/yui/compressor/
Come to mind. You'll want to take them for a spin with your own code, as a lot of factors come into play with minifying. Basically, see which one makes the smallest file (and verify that your code works as it should).
UglifyJS: https://github.com/mishoo/UglifyJS
The page contains a comparison with other minifiers if you scroll down a bit. One of the most notable parts is this:
UglifyJS is the fastest to run. On my laptop UglifyJS takes 1.35s for DynarchLIB, while YUI takes 2.7s and GCL takes 6.5s.
It written in JavaScript, so no need for separate runtimes etc. It plays nicely with both node.js and npm.
you can also try http://openwaf-js-mini.appspot.com ,slightly better than YUI Compressor
精彩评论