title: Cross-browser solution for a callback when loading multiple images?
body: <p>I checked other questions, but they all had information how to make a callback when one specific image has loaded:</p>
  
  <pre><code>var img = new Image();
  img.src = "images/img.png";
  if (!img.complete) {
      img.onload = function() {
          // code to be executed when the image loads
      }
  }
  </code></pre>
  
  <p>Or a simple check to see if all images are loaded with an 'if' statement. Also, $(window).load (or onLoad or whatever) doesn't work.</p>
  
  <p>In my case I'm loading two images:</p>
  
  <pre><code>var img1 = new Image();
  var img2 = new Image();
  img1.src = 'images/img1.png';
  img2.src = 'images/img2.png';
  </code></pre>
  
  <p>How can I define a callback similar to the one in the first example, but it gets executed when BOTH images have finished loading?</p>
  
  <p>Thank you for your time.</p>