title: Run JavaScript function after window load, including any asynchronous downloads
body: <p>I have an <code>initialise</code> function in my app that I want to trigger when two conditions have been met: 1) the window has loaded: <code>$(window).load()</code> and 2) Typekit has loaded.</p>
  
  <pre><code>$(window).load(function() {
      try {
          Typekit.load({ active: initialise });
      } catch (e) {}
  });
  </code></pre>
  
  <p>At the moment, this code is waiting until the window has loaded (including all resources e.g. images) before it starts to load the Typekit web fonts, and then, when they have loaded too, it will initialise.</p>
  
  <p>However, I want Typekit to load before the window has loaded. They should load asynchronously. So:</p>
  
  <pre><code>$(window).load(initialise);
  
  try {
      Typekit.load({ active: initialise });
  } catch (e) {}
  </code></pre>
  
  <p>Now the Web fonts are loading asynchronously, but the problem is, I need the <code>initialise</code> function to trigger only when both 1) the window has loaded: <code>$(window).load()</code> and 2) Typekit has loaded. Sometimes, the window will load before Typekit has loaded, and sometimes it is the other way round.</p>
  
  <p>So my question is: how can I trigger <code>initialise</code> as soon as both of my criteria have been fulfilled?</p>