Skip to content

Instantly share code, notes, and snippets.

@cdmz
Created January 26, 2016 02:30
Show Gist options
  • Save cdmz/7f57f3742a4ea30ce538 to your computer and use it in GitHub Desktop.
Save cdmz/7f57f3742a4ea30ce538 to your computer and use it in GitHub Desktop.
preload images javascript Jquery
jQuery.preloadImagesInWebPage = function() {
for (var ctr = 0; ctr < arguments.length; ctr++) {
jQuery("<img>").attr("src", arguments[ctr]);
}
}
//Carregando as imagens
$.preloadImages("image1.gif", "image2.gif", "image3.gif");
//verificar se imagem foi carregada.
$('#imageObject').attr('src', 'image1.gif').load(function() {
alert('A imagem foi carregada');
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment