JSFiddle - React, Tailwind, and code Playground
HTML
<div id="container">Loading...</div>
JavaScript
var frag = '<div><img src="http://www.lorempixel.com/99/99?v=' + Math.random() + '" /><img src="http://www.lorempixel.com/102/102?v=' + Math.random() + '" /><img src="http://www.lorempixel.com/103/103?v=' + Math.random() + '" /><div>Hello there</div></div>',
images = $(frag).find('img'),
loader = $('<img/>');
function iterate(i, callback) {
if (i > 0) {
i--;
loader.unbind("load");
loader.load(function() {
iterate(i, callback);
});
loader.attr('src', images[i].src);
}else{
callback();
}
}
iterate(images.length,function(){
console.log(images);
$('#container').html(frag);
});