jQuery preloading images


 / Published in: JavaScript
 

URL: http://www.innovatingtomorrow.net/2008/04/30/preloading-content-jquery

Thanks to Matt Farina

Also see similar snippet for preloading arbitrary content, e.g. media in content received via AJAX.

  1. // preloading function of images
  2. jQuery.preloadImages = function()
  3. {
  4. for(var i = 0; i<arguments.length; i++)
  5. {
  6. jQuery("<img>").attr("src", arguments[i]);
  7. }
  8. };
  9.  
  10. // use like
  11. $.preloadImages("image1.gif", "/path/to/image2.png", "some/image3.jpg");

Report this snippet  

You need to login to post a comment.