Javascript - preloading pics doesn't work?

b4u

Golden Member
Nov 8, 2002
1,380
2
81
Hi,

I'm developing an intranet solution, and it's almost done. Since I'm dealing with web technology, and this is a very dynamic tech, I've come to a point of configuring several "skins" for my app ...

For that, I use Cascade Style Sheets, and of course gif files with transparency. And that's were I came into a problem.

Accessing http://localhost/project/some_file.jsp, I get a really good looking app, with no performance penalty (at least none that can bee seen and pointed out).

But accessing through the IP address (http://172.168.0.10/project/some_file.jsp), somewhat simulating a network access, I get some penalty, and gif's take a bit longer to load, ruining the looks of skins generally.

One way of getting around this would be to preload pics, so the browser would have them at beginning ... but then, after testing it, it seems that browser doesn't really preload pics at all ...

For example, looking at the site http://www.pageresource.com/jscript/jhover.htm (which has a simple example of what I'm talking about), we see at some point an example of preloading working (search for "The Final Product: A Changing, Linked Image").

The problem is that, as I move the mouse over the image and out of it, the browser seems to download the image again and again ... I see the IE top-right icon temporarily moving, and the "Downloading ..." on the browser status bar ... for me, it's indicative that preloading isn't working ...

I tested at home, and still the same result ... I'm using "XP Pro with SP1 plus some hot extras" at work, and "XP Pro SP2 + all extras at home".

Can anyone give it a little test? Is there any other way of successfully load pictures for quick display?


One other thing I'm testing/using is for example applying a style from the Cascade Style Sheet, for example on a TR, and define a backgound on the Style Sheet itself, through the "background: url(...);" property. I will at some point change the style aplied on that TR, to another one with another background image. Is that any way of caching this images so that when the style changes it doesn't have to re-download pictures?


Thanks
 

b4u

Golden Member
Nov 8, 2002
1,380
2
81
Some More Info:

I believe that has something to do with IE settings:

I have the option "Check for newer versions of stored pages" set to "Every visit to the page". That way, it always goes searching for the images.

If I set it to "Automatically", it works just fine with that preload page example I gave ... but also works with no preloading at all, since the first download takes more time, but then the pics are in cache ... so anyway there would be no need for preloading ...

Any idea of how to preload to avoid extra downloading time, independently of the "Check for newer versions of stored pages" setting?