title: image.onload event and browser cache
body: <p>I want to create an alert box after an image is loaded, but if the image is saved in the browser cache, the <code>.onload</code> event will not be fired.</p>
  
  <p>How do I trigger an alert when an image has been loaded regardless of whether the image has been cached or not?</p>
  
  <pre><code>var img = new Image();
  img.src = "img.jpg";
  img.onload = function () {
     alert("image is loaded");
  }
  </code></pre>