JavaScript compression with Dojo Rhino

This is a modified version of Rhino (the Mozilla JS interpreter written in Java). We (the Dojo project) have added a “compressor” method to the built-in Decompile class. Since we’re operating on the token stream from the parser, this system is somewhat less prone to errors and “overzealousness”. A new “-c” flag sends the “compressed” version of the input to stderr. Normal invocation is:

java -jar js_with_compress.jar -c in.js > out.js 2>&1

This tool will NOT mangle your public APIs. We’re using it as a part of the build process in Dojo and it’s been working well for some time now. It’s much less error prone than the regexp-based stripper we used in netWindows.

Source for the tool (i.e., a zipped up version of my anonymous CVS checkout) is available in the same directory as the Jar file.


Comment by Alex Russell






Leave a Reply

Your email address will not be published. Required fields are marked *