Re: Preload Images

Giganews Newsgroups
Subject: Re: Preload Images
Posted by:  VK (schools_ri…
Date: Wed, 28 Nov 2007

On Nov 26, 2:17 pm, shapper <mdmo.…> wrote:
> Hello,
> How can I preload a few images of a page javascript?
> Should I use CSS to do this? Is it even possible?

That is a question. Initially in Netscape 3.x they introduced
scriptable .src property for images so developers could achieve roll-
over effects for graphics menu elements. To avoid load delays for the
first mouseover they also introduced Image constructor. The purpose of
this constructor was that by making
var imgOver = new Image;
imgOver.src = 'some/url';
script issued load request for the new image so it would be pre-
cashed. As DOM 0 supported by all - even the most lousy - modern
browsers the answer would be "Yes, it is easy, use Image objects on
page load". But as much as I remember, this feature exposed browsers
to numerous cache misuse, like
var bogusImg = new Image;
bogusImg.src = 'some/10Mb-100Mb/image';
and as I remember some precaution limitation had been made up to stop
caching images completely on imgObject.src="url" assignments.
What browsers still do such caching and if any left at all is a good
question to check.

P.S. Maybe that would also explain the origin of FAQ 4.31 that puzzled me all the time -
because no Web developers in any sanity would ever use server-side CGI
image generators for menu buttons nor would patch content header for
still images. I looked through the clj archives and the time this FAQ
was proposed overall matches to the period of "cache attacks" as my
weaked memory tells me :-) So possibly we have in this FAQ a dog
barking to an all wrong tree.



In response to

Preload Images posted by shapper on Mon, 26 Nov 2007