Created
April 30, 2014 18:06
-
-
Save bretdavidson/66c8f54faf5027a7ea93 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
// 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