Revision: 9504
Updated Code
at November 10, 2008 22:34 by nighthawk
Updated Code
// preloading function of images jQuery.preloadImages = function() { for(var i = 0; i<arguments.length; i++) { jQuery("<img>").attr("src", arguments[i]); } }; // use like $.preloadImages("image1.gif", "/path/to/image2.png", "some/image3.jpg");
Revision: 9503
Updated Code
at November 10, 2008 18:49 by nighthawk
Updated Code
// preloading function of images jQuery.preloadImages = function() { for(var i = 0; i<arguments.length; i++) { jQuery("<img>").attr("src", arguments[i]); } } // use like $.preloadImages("image1.gif", "/path/to/image2.png", "some/image3.jpg");
Revision: 9502
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at November 10, 2008 18:45 by nighthawk
Initial Code
// preloading function of images jQuery.preloadImages = function() { for(var i = 0; i<arguments.length; i++) { jQuery("<img>").attr("src", arguments[i]); } } // use like $.preloadImages("image1.gif", "/path/to/image2.png", "some/image3.jpg"); // preloading function for arbitrary content (which usually contains images) jQuery.preloadContent = function(){ for(var i = 0; i<arguments.length; i++) { jQuery("<div>").html(arguments[i]); } } // use like (myvar being a JS variable with content to preload) $.preloadContent(myvar1, myvar2);
Initial URL
http://www.innovatingtomorrow.net/2008/04/30/preloading-content-jquery
Initial Description
Thanks to Matt Farina Also see similar snippet for preloading arbitrary content, e.g. media in content received via AJAX.
Initial Title
jQuery preloading images
Initial Tags
javascript, jquery
Initial Language
JavaScript