Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
// Taken from: http://stackoverflow.com/a/476681
(function() {
var arrayOfImages = ["one.jpg", "two.jpg", "three.jpg"];
function preload(arrayOfImages) {
$(arrayOfImages).each(function () {
$('<img/>')[0].src = this;
});
}
//Usage:
preload(arrayOfImages);
}());
// Or as a jQuery plugin
(function () {
$.fn.preload = function() {
this.each(function(){
$('<img/>')[0].src = this;
});
};
// Usage:
$(['one.jpg','two.jpg','three.jpg']).preload();
}());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.