Created
May 3, 2014 20:10
-
-
Save mikekavouras/ffb5ae5bb625acd62a89 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
function preload(srcs, callback) { | |
var loaded = 0; | |
function loadOrError = function() { | |
loaded++; | |
if (loaded == srcs.length) { | |
if (callback) { | |
callback(); | |
} | |
} | |
} | |
for (var i = 0; i < srcs.length; i++) { | |
var src = srcs[i]; | |
var image = new Image(); | |
image.onload = loadOrError; | |
image.onerror = loadOrError; | |
} | |
} |
Author
mikekavouras
commented
May 3, 2014
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment