[Javascript] Pre-load images

David Hucklesby davidh126 at writeme.com
Thu Aug 14 20:04:59 CDT 2008


On Wed, 13 Aug 2008 12:50:52 -0400, tedd wrote:
> Hi gang:
>
> I have a script that pre-loads images (who doesn't?).
>

I don't.

If I need to pre-load images, I put them in a DIV that's off-lefted
(use your favorite off-left technique for this.) For good measure,
I include image attributes '<img ...width="1" height="0">' --
but this may not be necessary.


> Without the pre-load, I get major flashes on image roll-overs.
>
> With pre-load, it cuts the flashes down to almost nothing. But I still notice flashes
> occasionally on image roll-overs  -- is that to be expected? Is that a browser thing or
> should it not happen at all?
>

There is some JS mumbo-jumbo that can take care of this[1], but
I suggest putting a far future "expires" header on your images if you
can. This not only prevents the browser from trying to download images
a second or third time, but improves the speed of your pages on
subsequent visits:

<http://developer.yahoo.net/blog/archives/2007/05/high_performanc_2.html>

[1] <http://www.mister-pixel.com/>

Cordially,
David
--





More information about the Javascript mailing list