Posted By

nighthawk on 11/10/08


Tagged

javascript jquery webdev


Versions (?)

Who likes this?

12 people have marked this snippet as a favorite

jamesming
benrudolph
umang_nine
Hollow
xmartyxcorex
masondixon
seanpowell
creativeboulder
mmcachran
guo3823538
wirenaught
ringo380


jQuery preloading content


 / Published in: JavaScript
 

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

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.

  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);

Report this snippet  

You need to login to post a comment.