The following Javascript loads images into an array. This forces the images to be downloaded, so that when the page requires them the browser will automatically get them from the cache. Add this code the head section.
<script type="text/javascript">
function preloadImages()
{
var images=[];
for(i=0; i<arguments.length; i++)
{
images[images.length]=new Image();
images[images.length-1].src=arguments[i];
}
}
preloadImages('your.jpg','list.jpg','of.jpg','images.jpg','goes.jpg','here.jpg');
</script>
function preloadImages()
{
var images=[];
for(i=0; i<arguments.length; i++)
{
images[images.length]=new Image();
images[images.length-1].src=arguments[i];
}
}
preloadImages('your.jpg','list.jpg','of.jpg','images.jpg','goes.jpg','here.jpg');
</script>
Obviously (I hope), change the list of images passed in the call to the preloadImages function, to your own list of images.
Image Preload... Done.
Example: Preloaded images used for a slideshow
No comments:
Post a Comment