JSFiddle - React, Tailwind, and code Playground
HTML
<img src='http://pix.iemoji.com/images/emoji/apple/ios-9/256/unicorn-face.png' />
<img src='http://ffxiv.gamerescape.com/w/images/2/2f/Unicorn_Mount_Patch.png' />
<img src='https://pbs.twimg.com/profile_images/715703548441411585/bqlGs_jn.jpg' />
JavaScript
/**
* Exposes an event called "imagesLoaded" which is triggered
* when all images on the page have fully loaded.
*/
(function($) {
var loadImages = new Promise(function(done) {
var loading = $("img").length;
$("img").each(function() {
$("<img/>")
.on('load', function() {
loading--;
if (!loading) done();
})
.on('error', function() {
loading--;
if (!loading) done();
})
.attr("src", $(this).attr("src"))
});
});
loadImages.then(function() {
$(document).trigger({
type: "imagesLoaded"
});
});
})(jQuery);
$(document).on("imagesLoaded", function(){
alert("all images loaded");
})