PDA

View Full Version : Javascript Image preloader help



GedOfEarthsea
13 Jun 2009, 10:48 AM
Hello, I have been working on a website and there is a big problem on it somewhere. I am pretty sure it is the JavaScript that preloads the images.

Everytime I enter the site (sometimes on any page, but mostly on the "Our Work" page, I lose internet for 30-60+ seconds. I am not sure if this just affects me at home (I have done this on Windows XP, Windows 7, and OpenSUSE linux), or if this happens to anyone. Below is the JavaScript that I think is responsible:


function preloadImages() {
pic_main1 = new Image(10,10);
pic_main1.src = "images/wrapper.png";

pic_main2 = new Image(10,10);
pic_main2.src = "images/logo.jpg";

pic_main3 = new Image(10,10);
pic_main3.src = "images/welcome.jpg";

pic_main4 = new Image(10,10);
pic_main4.src = "images/navmenu.gif";

pic_main5 = new Image(10,10);
pic_main5.src = "images/top_gradient.gif";

pic_main6 = new Image(10,10);
pic_main6.src = "images/contact.jpg";


pic_main7 = new Image(10,10);
pic_main7.src = "images/navmenu_over.gif";

pic_main8 = new Image(10,10);
pic_main8.src = "images/origin-webs.jpg";

// Thumbnails

pic = new Image(10,10);

for (i=1;i<=16;i++) {
pic.src = "images/samples/" + i + "_thumbnail.jpg";
}

// Full Images

pic2 = new Image(10,10);

for (z=1;z<=16;z++) {
pic2.src = "images/samples/" + z + ".jpg";
}
}

I am not 100% sure if it is the js, but if it is I have a feeling it is happening because of the looping at the end.'

Below is a listing of the samples directory, so you can see the size of the images:


3283199 2009-05-15 21:10 1.jpg
357965 2009-05-15 21:07 10.jpg
63470 2009-05-15 21:09 10_thumb.jpg
419814 2009-05-15 21:07 11.jpg
64331 2009-05-15 21:09 11_thumb.jpg
537307 2009-05-15 21:08 12.jpg
68149 2009-05-15 21:09 12_thumb.jpg
569496 2009-05-15 21:08 13.jpg
76335 2009-05-15 21:09 13_thumb.jpg
459819 2009-05-15 21:07 14.jpg
62586 2009-05-15 21:09 14_thumb.jpg
572686 2009-05-15 21:08 15.jpg
64676 2009-05-15 21:09 15_thumb.jpg
617987 2009-05-15 21:08 16.jpg
76571 2009-05-15 21:09 16_thumb.jpg
97500 2009-05-15 21:07 1_thumb.jpg
2751790 2009-05-15 21:09 2.jpg
96435 2009-05-15 21:07 2_thumb.jpg
3118973 2009-05-15 21:10 3.jpg
84813 2009-05-15 21:08 3_thumb.jpg
3079359 2009-05-15 21:08 4.jpg
96583 2009-05-15 21:08 4_thumb.jpg
497606 2009-05-15 21:08 5.jpg
73065 2009-05-15 21:08 5_thumb.jpg
606253 2009-05-15 21:09 6.jpg
68719 2009-05-15 21:09 6_thumb.jpg
468438 2009-05-15 21:09 7.jpg
60846 2009-05-15 21:08 7_thumb.jpg
465284 2009-05-15 21:09 8.jpg
60977 2009-05-15 21:09 8_thumb.jpg
556587 2009-05-15 21:09 9.jpg
69786 2009-05-15 21:09 9_thumb.jpg

Any help in solving this problem would be greatly appreciated. If you need to see the site for better reference it is located here: http://www.jfenske.com/examples/cnydecks.com/Design%202/