We Recommend

HTML Dog: The Best-Practice Guide to XHTML and CSS HTML Dog: The Best-Practice Guide to XHTML and CSS
For readers who want to design Web pages that load quickly, are easy to update, accessible to all, work on all browsers and can be quickly adapted to different media, this comprehensive guide represents the best way to go about it.


Posted By

samuelcotterall on 03/31/08


Tagged

javascript js textmate jquery preload images


Versions (?)


Who likes this?

2 people have marked this snippet as a favorite

SmpleJohn
somedirection


Preload


Published in: Other 


  1. // Preloader
  2.  
  3. $(window).bind('load', function(){
  4. var preload = [
  5. '/bft/stunts/assets/images/alert_ticked.jpg',
  6. '/bft/stunts/assets/images/alert_unticked.jpg',
  7. '/bft/stunts/assets/images/back_hover.jpg',
  8. '/bft/stunts/assets/images/speech_bubble_right.png',
  9. '/bft/stunts/assets/images/speech_bubble_left.png',
  10. '/bft/stunts/assets/images/print_hover.jpg',
  11.  
  12. ];
  13. $(document.createElement('img')).bind('load', function(){
  14. if(preload[0]) this.src = preload.shift();
  15. }).trigger('load');
  16.  
  17. });

Report this snippet 

You need to login to post a comment.