JSFiddle - React, Tailwind, and code Playground

by minitech

HTML

<img src="http://r0k.us/graphics/kodak/kodak/kodim08.png" alt="Image">

JavaScript

// This code is being executed just before the closing `</body>` tag.
var img = document.images[0];

// Break the browser's cache of the image for this example.
var imgSrc = img.src + '?cache_bust=' + +new Date;

// Wait - replace it?
var pNode = img.parentNode;

pNode.removeChild(img);
img = document.createElement('img');
img.src = imgSrc;
pNode.appendChild(img);

// Should be `false` as the image has not loaded.
// Why is it returning `true`?
console.log(1, img.complete);

img.addEventListener('load', function() {
    // Should be `true` as the image *has* loaded.
    console.log(2, img.complete);    
}, false);