Monday, February 25, 2008

Compressing Javascript for zippy Ajax apps

A constant challenge with Ajax development is figuring how to get the widget code you need over to the browser as efficiently as possible. There are two issues here: 1) how to figure out exactly what Javascript needs to go on the client; and 2) how to make that Javascript download as small as possible.

The good counterexample here is the old Dojo download which was roundly criticized for being too large but Dojo has since trimmed down to a svelte 25K (take that jQuery fans!)

So the trick is to figure out what Javascript widgets need to get loaded to make your application run, then compress them to make them download faster. On the other hand, you need to make sure that uncompressing the download doesn't take more time than you saved in the download, as John Resig points out in his article on Javascript library loading speeds.

Brian Moschel of Jupiter IT in Chicago pinged me about a cool Javascript tool they developed called Include, that "makes compressing and including scripts ridiculously easy. It determines which files to compress at runtime and automatically compresses them using Dean Edwards'Packer." Check it out at javascriptmvc.com/include

No comments:

 
ss_blog_claim=3447bca5887ddff6d0ca4a390cd980a4