Reputation: 309
So I'm trying to make a jQuery slideshow.
I've read many tutorials, and pretty much all of them say to preload the images using some variation of the code below:
imageArray[imageNum++] = new imageItem(imageDir + "02.jpg");
imageArray[imageNum++] = new imageItem(imageDir + "03.jpg");
imageArray[imageNum++] = new imageItem(imageDir + "04.jpg");
imageArray[imageNum++] = new imageItem(imageDir + "05.jpg");
This is fine if you have four slides, however if the slide show has around 10 or 15 different slides, this can greatly decrease the speed of the website.
So the question persists, how can I get all of those pictures to the client and not cause such a big decrease in functionality?
Upvotes: 1
Views: 289
Reputation: 1
Actually, you don't need to preload the images in javascript. It's all about user comfort. preloading images in javascript give you the ability of showing to the user some feedback (loading gif, loading bar, %...) and say to him : wait a few second please. Otherwise, he will see nothing during a 2 or 3s (depend of the number and the size of the images). For example, in a basic html page with images (with no js) all is working but it may take a while to load the page.
That's why jquery (and other) slideshow snippet use JS loading.
Upvotes: 0
Reputation: 1833
You can try to preload only the image who will be next in the slideshow. Helpful link: http://engineeredweb.com/blog/09/12/preloading-images-jquery-and-javascript/
Upvotes: 2