PDA

Click to See Complete Forum and Search --> : Preload images


chalsema
11-29-2006, 01:20 PM
Is this the right javascript code to use to preload images on a web site:

<SCRIPT LANGUAGE = JAVASCRIPT>
if (document.images)
{
img1 = new Image();
img2 = new Image();
img1.src = "imageName1.gif";
img2.src = "imageName2.gif"
}
</SCRIPT>

Our load time is really really slow, and we think we're losing customers from it... do you think preloading the images will help? Or is there something else we can do?
Thanks!

Mynock
11-29-2006, 01:40 PM
Can you post it so we can take a look?

chalsema
11-29-2006, 01:41 PM
www.zionsvillecandlecompany.com

chalsema
11-29-2006, 01:51 PM
Maybe the problem is the javascript preload on the homepage?

JPnyc
11-29-2006, 02:10 PM
You also might wanna look into preloading images with css
http://www.netmechanic.com/news/vol6/css_no18.htm

chalsema
11-29-2006, 02:21 PM
Very interesting JP. That'll help for some of the secondary pages.

Mynock
11-29-2006, 02:23 PM
On the homepage it seems to take longer than it should, for some reason.

chalsema
11-29-2006, 02:28 PM
I agree. Probably because of the extra javascript nav section on the homepage... I just saved some of the images as PNG-8 instead of PNG-24, I think that'll help... but I can't tell because my browser has the images cached now.