JSFiddle - React, Tailwind, and code Playground
by jfriend00
HTML
<div id="output"></div>
CSS
body {font-family: "Courier New";}
JavaScript
var startTime = new Date();
function log(txt) {
var ticks = new Date() - startTime;
document.getElementById("output").innerHTML += ticks + "ms: " + txt;
}
var img = new Image();
img.onload = function() {
log("img onload fired - height=" + img.height + ", width=" + img.width + "<br>");
};
img.src = "http://photos.smugmug.com/photos/344291068_HdnTo-X2.jpg?rand=" + Math.floor(Math.random() * 10000000);
document.body.appendChild(img);
var timer = setInterval(function() {
if (img.width && img.height) {
log("polling - found height=" + img.height + ", width=" + img.width + "<br>");
clearInterval(timer);
}
}, 50);