Last active
August 29, 2015 14:01
-
-
Save theodesp/12d4804264ef0a8cdb16 to your computer and use it in GitHub Desktop.
A simple Javascript image preloader
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
/* Image Preloader | |
* imgpreload.js | |
* | |
* A simple Javascript image preloader | |
* Created by Theo Despoudis | |
* (c) 2014 Theo Despoudis. MIT open-source license. | |
*/ | |
; // Debloat | |
(function () { | |
var urls = [ | |
//Put some image urls here and let the Javascript handle the rest | |
], | |
images = []; | |
var L = urls.length; | |
for (var i = 0; i < L; i += 1) { | |
var image = new Image(); | |
image.src = urls[i]; | |
images.push(image); | |
} | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
My first Gist
Usage: Place the images you want to pre-load inside the specified array as strings.