title: Run jQuery code once jQuery loaded
body: <p>I have jQuery loaded before the closing  tag on my page.</p>
  
  <pre><code>    &lt;script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js" type="text/javascript"&gt;&lt;/script&gt;
  </code></pre>
  
  <p>The majority of my js is loaded below this in</p>
  
  <pre><code>    &lt;script src="js/script.js" type="text/javascript"&gt;&lt;/script&gt;
  </code></pre>
  
  <p>Which works well.
  There is some ad code that I need to run in the head tag.
  This works fine usually however I want to add a responsive exception.
  eg</p>
  
  <pre><code>    var mob = 0;
      if(jQuery(window).width() &lt; 727)  {
          mob = 1;
      }
      if(mob)  {console.log('run special mob related code');}
      else {console.log('run special desktop related code');}
  </code></pre>
  
  <p>Because my code is in the  I get the error ReferenceError: jQuery is not defined.
  Is there a way around this?
  The ad code doesn't run unless it is in the head, but I can't really move the jquery into the head as I have this on multiple sites and may affect how other plugins run?</p>