« Anderson on WPF, SWF | Main | Bloggers' credulousness »

May 22, 2006

Optimizing JavaScript

Optimizing JavaScript: Cal Henderson offers a lengthy guide at ThinkVitamin for speeding up the delivery of ambitious JavaScript work. He touches on one of the great ignored realities of web development: the number of separate HTTP transactions has an impact on startup time. Older HTTP transaction methods require four network messages each (response, request, finish and acknowledgement, if memory serves), and although HTTP 1.1 can pipeline several requests together, compliant browsers tend to limit the number of simultaneous resources delivered to two -- bottom line, the more URLs in a page, the longer it takes. (Classic Flash streams and can start very quickly; more modern Flash with high use of callable-at-any-time symbols has a longer startup but still doesn't suffer that need for multiple TCP/IP transactions.) Things get trickier when you consider multiple pages within a website, and your caching strategies for that content... using multiple external .JS libraries can cost more for the first page than for subsequent pages. Compression is also possible, but adds extra work on both server and client. One strategy he gets into towards the end is to set .JS files with an expiry date of ten years, and then change the names of these .JS files when you want to update them (which still seems creepy to me). Long article, but worth it for JavaScript development, I think, particularly if part of your audience uses slower connections or slower computers.

Posted by JohnDowdell at May 22, 2006 01:45 PM

Trackback Pings

TrackBack URL for this entry:
http://weblogs.macromedia.com/mtadmin/mt-tb.cgi/7441

Comments

More on that "creepy" bit: If you're going to use that technique, why not set the expiry to three months in the future? Asking visitors to download all your JavaScript every three months doesn't seem as bad as saying, essentially, "keep my stuff on your machine forever". If a spammer did such a thing there would be much umbrage....

Posted by: John Dowdell at May 22, 2006 07:46 PM