Skip to content

Instantly share code, notes, and snippets.

@ovdojoey
Created November 6, 2015 21:22
Show Gist options
  • Save ovdojoey/2951ecab75ebe191a5ca to your computer and use it in GitHub Desktop.
Save ovdojoey/2951ecab75ebe191a5ca to your computer and use it in GitHub Desktop.
Image Caching / Preloading
function imgPreloader () {
this.images = new Array();
this.addImages = function(images) {
var self = this;
if(!images) return;
if(Array.isArray(images)) {
images.forEach(function (ele) {
var _image = new Image();
_image.src = ele;
self.images.push(_image);
});
}
};
return this;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment