title: Adding jQuery to Magento
body: <p>What is the recommended way to add jQuery (or any script) BEFORE the rest of the scripts that come with Magento using local.xml? </p>
  
  <p>I've tried to use (in local.xml):</p>
  
  <pre><code>&lt;reference name="head"&gt;
      &lt;action method="addItem"&gt;
          &lt;type&gt;skin_js&lt;/type&gt;
          &lt;script&gt;js/jquery-1.6.4.js&lt;/script&gt;
      &lt;/action&gt;
  &lt;/reference&gt;
  </code></pre>
  
  <p>but this ends up adding jQuery to the end of the scripts that are added by Magento in page.xml in the base package. I've even tried removing all the scripts using:</p>
  
  <pre><code>&lt;action method="removeItem"&gt;
  ...
  &lt;/action&gt;
  </code></pre>
  
  <p>to remove all of the scripts that were added in page.xml and then re-adding them in local.xml in the order I need them to be in (jQuery first), but somehow, they are ending up in the same order (with jQuery last). </p>
  
  <p>I've stepped through the Magento code and verified that the scripts are getting removed and then re-added to $this->_data['items'] in Mage_Page_Block_Html_Head, but at some point, when they get added to the page, they are added with jQuery last.</p>
  
  <p>I'm guessing there has to be a more elegant way to do this, but I've yet to find it in my Googling. Everything I've found recommends modifying page.xml directly, which I've read elsewhere is not a good idea.</p>