title: jQuery .load() wait until content is loaded
body: <p>I want to make website pages sliding smothly one to another. So I've made $('a').click(); function that checks if link is local, and if is it gets a link href and loads it to body.</p>
  
  <pre><code>$('a').click(function(){
      var href=$(this).attr('href');  
      $('body').load(href);
      return false;
  });
  </code></pre>
  
  <p>It look nice, but my site has also a lot of js plugins included. Executing them takes a while, and <code>.load</code> action first shows 'unchanged by js' content, and then exectues js. It causes bad flickr of content.</p>
  
  <p>Is it possible to cache new content with all the exectuion of JS, dont change old body till it's done, and when all the DOM and JS is done on NEW content, slideOut old content and slideIn new one?</p>
  
  <p>edit:I think the point is not about detecting js execution but about checking if all additional files are loaded - DOM changing should be fired at the same time that $(window).load of new file would be.</p>
  
  <p><strong>[edit]----------------------------------------------------------------------</strong></p>
  
  <p>My solution for that was css code (css is loaded always before dom is build) that has cross-browser opacity 0.</p>
  
  <pre><code>.transparent{
      -moz-opacity: 0.00;
      opacity: 0.00;
      -ms-filter:"progid:DXImageTransform.Microsoft.Alpha"(Opacity=0);
      filter: progid:DXImageTransform.Microsoft.Alpha(opacity=0);
      filter:alpha(opacity=0);
  }
  </code></pre>
  
  <p>And it prevent from bad flickr of content usually but not always. Now its possible to detect somehow that content is loaded by jQuery ajax and apply some show timeout and so on. But in fact question is still open.</p>
  
  <p>To make now a little more simple example for that question:</p>
  
  <p>How to begin changing DOM after $('body').load('something.php') 3000ms after clicking the link that fire .load('something.php') function? (Loading should be started instantly after clicking, but DOM changing has to be initiated later)</p>