JSFiddle - React, Tailwind, and code Playground

HTML

<!DOCTYPE html>
<html>
  <head>
    <title>Onload event using Javascript</title>
    <link rel="stylesheet" href="styles.css" />
  </head>
  <body>
      <h1 class="title">Onload event using Javascript</h1>
      <p id="currentTime"></p>
      <script src="script.js"></script>
      <img src="https://secure.gravatar.com/avatar?d=wavatar">
  </body>
</html>

JavaScript

window.addEventListener("load", event => {
    var image = document.querySelector('img');
    var isLoadedSuccessfully = image.complete && image.naturalWidth !== 0;
    alert(isLoadedSuccessfully);
});