title: Load Google Analytics from jQuery document ready?
body: <p>The problem is that GA sometimes takes a little while to load, and my jQuery ready() functions don't run until it's done.  I'd like to move the GA code itself to the end of the ready() function. I'm not looking for extra click tracking integration - I just want my ready() scripts to run first.</p>
  
  <p>My questions are:
  1) Will moving the GA code break their stat tracking in any way? And,
  2) Do I need to emulate their use of two script tags (one that generates the external script tag, and one that calls the function)? If so, why, and what's the best way to do that in a jQuery function?</p>
  
  <p>To explain #2, here's the GA code that currently goes just before the closing body tag:</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
  var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
  document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
  &lt;/script&gt;
  &lt;script type="text/javascript"&gt;
  try {
  var pageTracker = _gat._getTracker("UA-8704511-1");
  pageTracker._trackPageview();
  } catch(err) {}&lt;/script&gt;
  </code></pre>