Advertisement
Guest User

Untitled

a guest
Jan 15th, 2012
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.98 KB | None | 0 0
  1. /*!
  2. * $.preload() function for jQuery – http://mths.be/preload
  3. * Preload images, CSS and JavaScript files without executing them
  4. * Script by Stoyan Stefanov – http://www.phpied.com/preload-cssjavascript-without-execution/
  5. * Slightly rewritten by Mathias Bynens – http://mathiasbynens.be/
  6. * Note that since this script relies on jQuery, the preloading process will not start until jQuery has finished loading.
  7. */
  8.  
  9. jQuery.preload = function(array) {
  10. var length = array.length,
  11. document = window.document,
  12. body = document.body,
  13. isIE = 'fileSize' in document,
  14. object;
  15. while (length--) {
  16. if (isIE) {
  17. new Image().src = array[length];
  18. continue;
  19. }
  20. object = document.createElement('object');
  21. object.data = array[length];
  22. object.width = object.height = 0;
  23. body.appendChild(object);
  24. }
  25. };
  26.  
  27. // Example:
  28.  
  29. $(function() {
  30. $.preload([
  31. 'http://hang.nodester.com/foo.png?2000',
  32. 'http://hang.nodester.com/foo.js?2000',
  33. 'http://hang.nodester.com/foo.css?2000'
  34. ]);
  35. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement