title: Load jquery core asynchronous with fallback
body: <p>With performance optimization and non-blocking scripts in header, I've been trying to asynchronously load the jquery itself.</p>
  
  <p>I ran into a <a href="http://www.yterium.net/jQl-an-asynchronous-jQuery-Loader" rel="nofollow">jQuery Loader</a> script, that <strong>async</strong> loads jquery and thereafter catches and queues jquery document ready calls. This seems to work most of the time, but not always. </p>
  
  <p>So I created a fallback to load a local jquery version if the loader hasn't finished within x seconds. The fallback works, but not completely. Some parts may work, others not.</p>
  
  <p>Script so far called in head, after loading the jquery loader script:</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
  function loadScript(url)
  {
      var head = document.getElementsByTagName('head')[0];
      var script = document.createElement('script');
      script.type = 'text/javascript';
      script.src = url;
      head.appendChild(script);
  }
  
  var fallback_timer = setTimeout(function() {
      loadScript('/path/to/local/js/jquery.js');
  },5000);
  jQl.loadjQ('//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js',function({clearTimeout(fallback_timer);});
  
  &lt;/script&gt;
  </code></pre>
  
  <p><strong>Questions:</strong></p>
  
  <ol>
  <li><p>Anyone with experience with jQuery Loader (jQl) that can help out fixing the
  issue that it fails regularly?</p></li>
  <li><p>Anyone who can tell me why, incase of failure, only some of my other
  js scripts work, but some keep failing?</p></li>
  <li><p>I am very open to asynchronously loading jquery core with some other
  plugin/script/direction to look for.</p></li>
  </ol>
  
  <p>To clarify, I am not looking at asynchronously loading scripts using jQuery, but loading the jquery itself asynchronously while supporting loading jquery dependent scripts somewhere down the road.</p>