JSFiddle - React, Tailwind, and code Playground

JavaScript

function loadImages(images, callback) {
    var length, count, check, i, img;
    
    length = images.length;
    count = length;
    
    check = function () {
        if (--count === 0) {
            callback();
        }
    };
    
    for (i = 0; i < length; i++) {
        img = new Image();
        
        img.onload = check;
        img.onerror = check;
        
        img.src = images[i]
    }
}

var images = [
    'http://lorempixel.com/g/400/200/',
    'http://lorempixel.com/g/300/200/',
    'http://lorempixel.com/g/200/200/',
    'http://lorempixel.com/g/500/300/',
    'http://lorempixel.com/g/600/800/',
    'http://lorempixel.com/g/800/800/',
    'http://lorempixel.com/g/900/700/',
    'http://lorempixel.com/g/1000/800/'
];

var html = '';

images.forEach(function (image) {
    html += '<img src="' + image + '" />';
});

loadImages(images, function () {
    document.body.innerHTML = html;
});