Skip to content

Instantly share code, notes, and snippets.

@lonekorean
Last active August 29, 2015 13:55
Show Gist options
  • Select an option

  • Save lonekorean/8756498 to your computer and use it in GitHub Desktop.

Select an option

Save lonekorean/8756498 to your computer and use it in GitHub Desktop.
Still bad image preloader
// better, but still not good
function imageLoaded(i) {
alert(i);
}
for (var i = 0; i < max; i++) {
var image = new Image();
image.onload = function () { imageLoaded(i) };
// more irrelevant stuff here
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment