Information Technology Reference
In-Depth Information
This tells YUI Compressor to compress main.js into a smaller file named main.small.js .
In this case, the compressor cut the file size from 3,763 bytes to 1,946— a little more
than half!
There are a few other compressing applications out there that are definitely worth
mentioning. The first one I would like to take a look at is a handy little application
created by Dean Edwards called Packer ( http://dean.edwards.name/packer/ ) shown in
Figure 13-5. This web service will allow you to copy your development JavaScript into a
textarea field on the site and with a quick click of a button spit out shrunken JavaScript
code that you can just copy and paste into a blank text file and be on your way. If you
believe that YUI might be a bit of overkill for your particular needs, Packer might be a
great and extremely simple-to-use alternative.
One should note, however, that while Packer is a great tool for shrinking code, it is also
quite easy to unobscurethis code by simply disabling the JavaScript that prevents you
from pasting code into the “Copy” box and hitting “decode”! Therefore one should use it
as simply a compressor, not a security mechanism.
Figure 13-5. Using Packer we can painlessly minify our "Who's That Tweet?" JavaScript code from Chapter 2,
which is in the top textarea field, into something that is just a tiny fraction of the original document size as seen in
the bottom textarea
 
Search WWH ::




Custom Search