Javascript image preload strategy -
like many people i've been doing image preload long time, not rationally. i've come short list of thoughts right way preload images javascript.
- an image preload script should executed possible. should placed @ top of html (in head section), unlike others scripts go bottom of body section.
- it must not rely on library (such jquery) because delay execution.
- css sprites , background-images need not preloaded because css - called @ top of html - job (this of course reduces overall need javascript image preload).
- the preload script can placed , run on every page of site sure effective no matter page user enters site. (but overhead of running script every time, if check images cached?)
i'd interested hear opinions on subject.
an image preload script should executed possible. should placed @ top of html (in head section), unlike others scripts go bottom of body section.
this puts greater precedence on images might shown if user on images part of initial page. (unless trying preload images part of initial page, redundant).
it must not rely on library (such jquery) because delay execution.
such delay shouldn't significant
css sprites , background-images need not preloaded because css - called @ top of html - job (this of course reduces overall need javascript image preload).
browsers may optimize , not load images mentioned in stylesheets if aren't being displayed.
the preload script can placed , run on every page of site sure effective no matter page user enters site. (but overhead of running script every time, if check images cached?)
sensible cache control headers should avoid need make http requests check freshness of images, should negligible.
Comments
Post a Comment