title: Execute JavaSCript code after image preload
body: <p>I'm trying to create some kind of callback code which gets executed after an image has been preloaded.</p>
  
  <p>My JS code is as follows:</p>
  
  <pre><code>&lt;script type='text/javascript'&gt;
  d=document;
  window.onload=function()
  {
     if (d.images)
     {
        d.getElementById('preload').style.display='block';
        i1=new Image;
        i1.src="http://link_to_image";
        d.getElementById('preload').style.display='none';
     }
  }
  &lt;/script&gt;
  </code></pre>
  
  <p>So in my example, <code>d.getElementById('preload').style.display='none';</code> should be executed after the image has been fully loaded into the cache.</p>
  
  <p>Any help on how to achieve this? Please only standalone JavaScript solutions without library/plugin requirements.</p>