Return to Snippet

Revision: 9506
at November 10, 2008 22:34 by nighthawk


Updated Code
// 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);

Revision: 9505
at November 10, 2008 18:50 by nighthawk


Initial Code
// 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

This snippet is useful for preloading content with media that has been received via an AJAX request. For simple preloading of known images, see similar snippet.

Initial Title
jQuery preloading content

Initial Tags
javascript, jquery

Initial Language
JavaScript