title: How to add a custom javascript in a Magento extension
body: <p>I'm trying to add a javascript to all Magento pages inside tag <code>&lt;head&gt;</code>. I have a file called <code>example.xml</code> in this folders tree (I've made a configuration on <code>etc/config.xml</code> to use a custom .xml file like <code>example.xml</code>):</p>
  
  <pre><code>--design
  ----frontend
  ------base
  --------default
  ----------layout
  ------------example.xml
  </code></pre>
  
  <p>I'm using two approaches to do this. The first one is (NOT WORKING):</p>
  
  <pre><code>&lt;layout&gt;
  &lt;default&gt;
      &lt;reference name="head"&gt;
          &lt;action method="addJs"&gt;
              &lt;script&gt;folder/myjavascript.js&lt;/script&gt;
          &lt;/action&gt;
      &lt;/reference&gt;
  &lt;/default&gt;
  &lt;/layout&gt;
  </code></pre>
  
  <p>The second one is (WORKING only for checkout page):</p>
  
  <pre><code>&lt;layout&gt;
      &lt;example_handle&gt;
          &lt;reference name="head"&gt;
              &lt;action method="addJs"&gt;
                  &lt;script&gt;folder/myjavascript.js&lt;/script&gt;
              &lt;/action&gt;
          &lt;/reference&gt;
      &lt;/example_handle&gt;
  
      &lt;checkout_onepage_index&gt;
          &lt;update handle="example_handle"/&gt;
      &lt;/checkout_onepage_index&gt;
  
      &lt;onepagecheckout_index_index&gt;
          &lt;update handle="example_handle"/&gt;
      &lt;/onepagecheckout_index_index&gt;
  
      &lt;opc_index_index&gt;
          &lt;update handle="example_handle"/&gt;
      &lt;/opc_index_index&gt;
  
      &lt;aw_onestepcheckout_index_index&gt;
          &lt;update handle="example_handle"/&gt;
      &lt;/aw_onestepcheckout_index_index&gt;
  &lt;/layout&gt;
  </code></pre>
  
  <p>My javascript has a snippet where I need to get a custom variable from Magento (in php I use <code>getConfigData('api_key')</code>). So, my second question is: Is it possible to get this value directly from javascript or I need to do this with php?</p>
  
  <pre><code>var _api_key = ?`getConfigData('api_key')`?;
  </code></pre>