Skip to content

Instantly share code, notes, and snippets.

@rodrigogmdias
Last active December 31, 2015 18:09
Show Gist options
  • Save rodrigogmdias/8024626 to your computer and use it in GitHub Desktop.
Save rodrigogmdias/8024626 to your computer and use it in GitHub Desktop.
Função de Preload de Imagens no Javascript
function preloadImages(images, callback) {
var count = images.length;
if(count === 0) {
callback();
}
var loaded = 0;
$(images).each(function() {
$('<img>').attr('src', this).load(function() {
loaded++;
if (loaded === count) {
callback();
}
});
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment