Online Dojo JavaScript Compressor
Posted in dojo, ajax, scriptaculous, prototype Fri, 28 Jul 2006 17:14:00 GMT
I just put together an online JavaScript Compressor interface to Dojo Toolkit's JavaScript Compressor, custom_rhino.jar. The JavaScript Compressor is used in the final stage of the Dojo Toolkit build process so gets a lot of use. Although there is already an online version, ShrinkSafe, I put another version together because:
- It would be nice to have a web app that makes custom Dojo builds people don't have to install the JDK and ant to get a custom Dojo build. This is the primary reason and the compressor is a first step in that direction.
- There have been some reports that the JS produced by ShrinkSafe doesn't work (maybe it's using an outdated custom_rhino.jar?). I want an Dojo-based online system to use myself.
- It's nice to have more Dojo, Prototype and Scriptaculous integration tests. I used the client code from ShrinkSafe which uses Dojo to add additional file and do Drag-and-Drop along with the Lucid theme which relies on Prototype and Scriptaculous. I learned that dojo.js 0.3.1 needs to be loaded before scriptaculous.js 1.6.1 or Scriptaculous will break Dojo (I updated the Dojo and Prototype Together article). My minimal use of the Lucid theme actually doesn't need scriptaculous.js so I can get away with loading just dojo.js 0.3.1, prototype.js 1.5.0 rc0, effects.js (part of Scriptaculous 1.6.1) and lucid.js. lucid.js is part of the Lucid theme.
The JavaScript compressor eats its own dogfood and uses prototype.js, effects.js and lucid.js compressed into a single-line, single file. Here are the compression sizes and ratios for the files. Generally you save about 30%.
script | uncompressed | compressed multiline |
ratio | compressed single line |
ratio |
---|---|---|---|---|---|
prototype.js | 55,149 | 38,696 | 70% | 37,154 | 67% |
effects.js | 32,908 | 23,244 | 71% | 22,527 | 68% |
lucid.js | 7,253 | 4,917 | 68% | 4,741 | 65% |
All files | 95,310 | 67,570 | 71% | 65,137 | 68% |
A number of people are using JavaScriptCompressor.com which is running Dean Edwards' .NET JavaScript compression code. This can be used after Dojo's compressor for even more compression.
Great work! Can you tell us how to enable “strip newlines” option for custom_rhino?
I put the strip newlines functionality in the perl script. If the functionality is in custom_rhino, it’s probably in Mozilla’s Rhino which custom_rhino is based on (but I’m not sure if it is).
I’m trying to write a bash script to run the compressor on a number of javascript files, but it’s very confusing. could you please explain the command line options for custom_rhino. I cannot find the relevant script in the source code for love nor money http://download.dojotoolkit.org/release-0.4.1/
wou!!! this aplicattion is great!!
thank very much!
This doesn’t seem to work anymore. Also you might want to check out what the page looks like in IE!