Skip to content

Instantly share code, notes, and snippets.

@0xnbk
Created September 13, 2010 04:14
Show Gist options
  • Save 0xnbk/576794 to your computer and use it in GitHub Desktop.
Save 0xnbk/576794 to your computer and use it in GitHub Desktop.
Preloading images
jQuery.preloadImages = function()
{
for(var i = 0; i").attr("src", arguments[i]);
}
};
// Usage
$.preloadImages("image1.gif", "/path/to/image2.png", "some/image3.jpg");
@0xnbk
Copy link
Author

0xnbk commented Sep 13, 2010

Preloading images

When you’re using images in Javascript, a good thing is to preload it before you have to use it. This code will do the job:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment