Preload a List of Images


/ Published in: JavaScript
Save to your folder(s)

Preloads a list of difined images to the browser cache


Copy this code and paste it in your HTML
  1. <!--
  2.  
  3. if (document.images)
  4. {
  5. preload_image_object = new Image();
  6. // set image url
  7. image_url = new Array();
  8. image_url[0] = "http://mydomain.com/image0.gif";
  9. image_url[1] = "http://mydomain.com/image1.gif";
  10. image_url[2] = "http://mydomain.com/image2.gif";
  11. image_url[3] = "http://mydomain.com/image3.gif";
  12.  
  13. var i = 0;
  14. for(i=0; i<=3; i++)
  15. preload_image_object.src = image_url[i];
  16. }
  17.  
  18. //-->

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.