Welcome to WebmasterWorld Guest from

Forum Moderators: open

Message Too Old, No Replies

Javascript preloading

It doesn't always work.

12:41 am on Dec 20, 2001 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month

joined:Oct 4, 2001
votes: 17

Has anyone else noticed this?

I'm talking about using the standard javascript:

name = new Image(x,x);
name.src = "./url/image.gif";

I use this both for preloading mouseovers and, sometimes, for preloading images on the next page.

The problem I've encountered is that, sometimes, mouseover images are not preloaded once the document has finished loading. Instead there is a pause onmouseover while the image is fetched from the server.

On top of that, there is sometimes a pause onmouseout while the original image is re-fetched. Also, this images are not catched after the first mouseover... They are continually refetched.

I have always written this off as a quirk of whatever broswer I was using at the time and forgotten about it. My thinking being that A, it doesn't always happen and B, javascript preloading is so universally used that it must actually work :-)

I'm not so sure, anymore... I've seen this problem in multiple versions of IE (including 5.x) and, now, in Netscape 6 the image being currently displayed will actually disappear while the replacement image is loaded both onmouseout and onmouseover.

The strange thing is that this is that this does not always happen. I just tried clearing the disk cache in NS6 and then reloading the page... Everything worked perfectly.

Stranger and stranger... Has anyone else noticed this? Any workarounds?

1:12 am on Dec 20, 2001 (gmt 0)

Senior Member

WebmasterWorld Senior Member tedster is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:May 26, 2000
votes: 0

Yep, I've seen these and other brower cache quirks in both NN and IE -- it's as if they get befuddled and forget where thye stashed the file. However, I've never seen the browser go back to the server for an onMouseOut image that was previously rendered, unless one path was relative and the other absolute.

I'd like to understand this better -- I don't have any work-arounds either.