title: Detect if page has finished loading
body: <p>Is there a way to detect when a page has finished loading ie all its content, javascript and assets like css and images?</p>
  
  <p>so like:</p>
  
  <pre><code>if(PAGE HAS FINISHED LOADING)
  {
  // do something amazing
  }
  </code></pre>
  
  <p>and also additionally if the page has been loading for more than 1 min then do something else such as:</p>
  
  <pre><code>if(PAGE HAS BEEN LOADING FOR 1 MIN)
  {
  // do something else amazing
  }
  </code></pre>
  
  <p>I've seen websites like Apple's MobileMe do similar checks but haven't been able to figure it out in their huge code libraries.</p>
  
  <p>Can anyone help?</p>
  
  <p>Thanks</p>
  
  <p>EDIT: This is essentially what I want to do:</p>
  
  <pre><code>// hide content
  $("#hide").hide();
  
  // hide loading
  $("#loading").hide();
  
  // fade in loading animation
  setTimeout($('#loading').fadeIn(), 200);
  
  jQuery(window).load(function() {
    $("#hide").fadeIn();
  
    $("#loading").fadeOut(function() {
      $(this).remove();
      clearInterval(loadingAnim);
    });
  
    setTimeout(function() {
      $("#error").fadeIn();
    }, 60000);
  });
  </code></pre>