jQuery image preload/cache halting browser
- by Nathan Loding
In short, I have a very large photo gallery and I'm trying to cache as many of the thumbnail images as I can when the first page loads. There could be 1000+ thumbnails.
First question -- is it stupid to try to preload/cache that many?
Second question -- when the preload() function fires, the entire browser stops responding for a minute to two. At which time the callback fires, so the preload is complete. Is there a way to accomplish "smart preloading" that doesn't impede on the user experience/speed when attempting to load this many objects?
The $.preLoadImages function is take from here: http://binarykitten.me.uk/dev/jq-plugins/107-jquery-image-preloader-plus-callbacks.html
Here's how I'm implementing it:
$(document).ready(function() {
setTimeout("preload()", 5000);
});
function preload() {
var images = ['image1.jpg', ... 'image1000.jpg'];
$.preLoadImages(images, function() { alert('done'); });
}
1000 images is a lot. Am I asking too much?