JSFiddle - React, Tailwind, and code Playground
HTML
<img width="100" src="http://i.imgur.com/zcRCz.jpg">
<img width="100" src="
http://i.imgur.com/VpCQD.jpg">
<img width="100" src="
http://i.imgur.com/TUvUg.png">
<img width="100" src="
http://i.imgur.com/GGeox.jpg">
JavaScript
var n=0;
var c=0;
$('img').each(function() {
n++;
var tmpImg = new Image() ;
tmpImg.src = $(this).attr('src') ;
tmpImg.onload = function() {
c++;
};
});
var interval = setInterval(function() {
percent = n/100;
loaded = c/percent;
// for displaying purposes
$('body').append(loaded+'<br />');
// feed loaded var to the progressbar
if (loaded == 100) {
clearInterval(interval);
}
}, 1);