What I'm doing right now is using the following function to preload images to cache. I was wondering if it is possible to load them from memory for even faster load time.
function preloadImage (done, i) {
if (!i) { i = 1; }
var img = new Image();
img.onloadend = function () {
if (this.height == 0) { return done(); }
preloadImage(done, i + 1);
};
img.src = "images/" + i;
}
preloadImage(function () { console.log('images loaded'); });
What I want to do is to load an array of image()
elements with javascript and then show them in a slideshow.