nakome
2/13/2016 - 4:20 AM

Image preloader javascript

Image preloader javascript

function preload(imageArray, index) {
        index = index || 0;
        if (imageArray && imageArray.length > index) {
            var img = new Image ();
            img.onload = function() {
                preload(imageArray, index + 1);
            }
            img.src = images[index][‘serving_url’];
}
/* images is an array with image metadata */
preload(images);