JSFiddle - React, Tailwind, and code Playground

HTML

<body>
    <button id="button">Update document</button>
</body>

JavaScript

// Real implementation will do an AJAX request to retrieve new
// document content. This one just sets a timeout instead.
$('#button').on('click', function doAjaxRequest() {
    // This function changes the document content so that it
    // contains new uncached images.
    window.setTimeout(function changeContent() {
        document.body.innerHTML = '<div style="background-image:url(\'http://lorempixel.com/800/600/abstract/?' + Math.random() + '\'); height:600px; width:800px;"></div>';
        // This handler should run when new conent
        // is ready and all images are loaded.
        // BOT IT DOES NOT :(
        $(window).on('load', function onLoad() {
            alert('Document updated successfully.');
        });
    }, 1000);
});