Created
September 13, 2010 04:14
-
-
Save 0xnbk/576794 to your computer and use it in GitHub Desktop.
Preloading images
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
jQuery.preloadImages = function() | |
{ | |
for(var i = 0; i").attr("src", arguments[i]); | |
} | |
}; | |
// Usage | |
$.preloadImages("image1.gif", "/path/to/image2.png", "some/image3.jpg"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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: