Posted By

1man on 01/13/10


ajax jquery preload cache

Versions (?)

Who likes this?

1 person have marked this snippet as a favorite


Cache files with jQuery and ajax method

 / Published in: jQuery

Handy little snippet i found in 'jquery enlightenment' for caching certain selected files. Could be useful for larger files later on in a site.

  1. (function($){
  2. $(window).load(function(){
  3. //Wait for the page to load, the cache the files you want
  4. $.ajax({url:'javascript.js', dataType:'text'});
  5. $.ajax({url:'image.jpg', dataType:'text'});
  6. $.ajax({url:'flash.swf', dataType:'text'});
  7. $.ajax({url:'style.css', dataType:'text'});
  8. });
  9. })(jQuery);

Report this snippet  

You need to login to post a comment.