Skip to content

Instantly share code, notes, and snippets.

@hungsu
Created September 24, 2013 07:14
Show Gist options
  • Save hungsu/6681307 to your computer and use it in GitHub Desktop.
Save hungsu/6681307 to your computer and use it in GitHub Desktop.
Preload an image into browser cache (but not the DOM)
function preload(arrayOfImages) {
$(arrayOfImages).each(function(){
(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