Created
July 17, 2012 14:47
-
-
Save marcosbrasil/3129837 to your computer and use it in GitHub Desktop.
Simple extend jquery plugin for load images into DOM
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
var cache = []; | |
// Arguments are image absolute paths to the current page | |
$.preLoadImages = function(arrImg,funcCallback) { | |
var imgLen = arrImg.length; | |
for (var i = imgLen; i>=0 ;i--) { | |
if(typeof arrImg[i] !== 'undefined'){ | |
var cacheImage = document.createElement('img'); | |
cacheImage.src = arrImg[i]; | |
cache.push(cacheImage); | |
} | |
} | |
// calling the callback | |
if(typeof funcCallback == 'function'){ | |
return funcCallback.call(this); | |
} | |
} | |
//Relly simple exemple | |
var arrImage = ["http://urlimg1","http://urlimg1","http://urlimg..N"]; | |
jQuery.preLoadImages(arrImage, function(){ | |
console.log('Function Callback'); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment