Skip to content

Instantly share code, notes, and snippets.

@zacscott
Last active December 27, 2015 14:49
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zacscott/7343450 to your computer and use it in GitHub Desktop.
Save zacscott/7343450 to your computer and use it in GitHub Desktop.
jQuery plugin to preload images.
/** jQuery plugin to preload images */
$.fn.preload = function() {
this.each(function(){
$('<img/>')[0].src = this;
});
}
// use like so:
$(['img/pic1.jpg', 'img/pic2.jpg', ...]).preload();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment