Skip to content

Instantly share code, notes, and snippets.

@cam-gists
Created August 20, 2012 15:53
Show Gist options
  • Select an option

  • Save cam-gists/3405327 to your computer and use it in GitHub Desktop.

Select an option

Save cam-gists/3405327 to your computer and use it in GitHub Desktop.
JQuery: Preload Images
function preload(arrayOfImages)
{
$(arrayOfImages).each(function(){
$('<img/>')[0].src = this;
// Alternatively you could use:
// (new Image()).src = this;
});
}
// Usage:
preload([
'imgs/1.jpg',
'imgs/2.jpg'
]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment