title: How can I fire jQuery outside document.ready block?
body: <p>The common method of starting jQuery is putting it in</p>
  
  <pre><code>$(document).ready(function() {
      // put all jQuery stuff here
  });
  </code></pre>
  
  <p>But what if I have a complicated site which uses basic jQuery in <code>&lt;head&gt;</code> <strong>and</strong> some custom functions that depend on the page type (e.g. if I have login page, fire some login ajax stuff).</p>
  
  <p>So, how can I attach code to <code>$(document).ready()</code> <strong>or</strong> fire it later? Which JS syntax should I use?</p>
  
  <p>Thanks for help!</p>
  
  <hr>
  
  <p>My page structire is similar to this:</p>
  
  <ol>
  <li>Display <strong>static</strong> header using PHP's <code>include()</code></li>
  <li>Add content inside <code>&lt;body&gt;&lt;/body&gt;</code></li>
  <li>Display the template footer</li>
  </ol>
  
  <hr>
  
  <pre><code>&lt;?php
  
  include_once('system/classes/class.display.php');
  
  $d = new IFDisplay();
  
  $d-&gt;display_header(array('subtitle' =&gt; 'Log In')); &lt;-- Here it displays static
                                                         head tags. There is
                                                         document.ready in there.
                                                         I can't change it.
  
  ?&gt;
  
  &lt;script type="text/javascript"&gt;
  AND WHAT DO I NEED TO PUT HERE
  &lt;/script&gt;
  
  &lt;div&gt;...&lt;/div&gt;
  
  &lt;?php
  
  $d-&gt;display_footer();
  
  ?&gt;
  </code></pre>