[Javascript] Organizing onload events

Bill Moseley moseley at hank.org
Sat Sep 23 08:40:05 CDT 2006


On Fri, Sep 22, 2006 at 11:04:28PM -0700, Paul Novitski wrote:
> The primary trade-off seems to concern cache:  if you can tolerate a 
> long initial load, then the big js file is in cache and won't be 
> loaded again (until the user clears their cache or explicitly reloads 
> the browser content).  If you break your script down into many 
> smaller parts and load them as needed, then you distribute the 
> response time lag more evenly over the experience of browsing the 
> site.  Which way you go on any given project will depend on a dozen 
> variables, including your expectation of how long (for how many 
> page-views) an average user is likely to stay and how big "big" is, 
> even on dial-up.

And make sure your web server is returning correct caching control
instructions to the browser.  mod_expires on Apache.

I also compress the large javascript files.  Used to be some debate
about doing this, but it's probably a win these days.  mod_deflate on
Apache.

-- 
Bill Moseley
moseley at hank.org




More information about the Javascript mailing list