Skip to content

Instantly share code, notes, and snippets.

@jorgeguberte
Forked from martinluz/gist:4529970
Created February 14, 2013 18:15
Show Gist options
  • Save jorgeguberte/4954896 to your computer and use it in GitHub Desktop.
Save jorgeguberte/4954896 to your computer and use it in GitHub Desktop.
//Source: http://stackoverflow.com/a/476681
function preload(arrayOfImages) {
$(arrayOfImages).each(function(){
$('<img/>')[0].src = this;
// Alternatively you could use:
// (new Image()).src = this;
});
}
// Usage:
preload([
'img/imageName.jpg',
'img/anotherOne.jpg',
'img/blahblahblah.jpg'
]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment