jQuery preloading content


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

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.


Copy this code and paste it in your HTML
  1. // preloading function for arbitrary content (which usually contains images)
  2. jQuery.preloadContent = function(){
  3. for(var i = 0; i<arguments.length; i++)
  4. {
  5. jQuery("<div>").html(arguments[i]);
  6. }
  7. };
  8.  
  9. // use like (myvar being a JS variable with content to preload)
  10. $.preloadContent(myvar1, myvar2);

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

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.