title: Javascript Include Tag Best Practice in a Rails Application
body: <p>Say I need to call a javascript file in the <code>&lt;head&gt;</code> of an ERb template.
  My instinct is to do the usual:</p>
  
  <pre><code>&lt;head&gt;
  &lt;%= javascript_include_tag :defaults %&gt; &lt;!-- For example --&gt;
  &lt;/head&gt;
  </code></pre>
  
  <p>in my application's layout. The problem of course becoming that these javascript files are loaded into every page in my application, regardless of whether or not they are needed for the page being viewed.</p>
  
  <p>So what I'm wondering is if there's a good way of loading a javascript into the the headers of, for example, all ERb templates found only in a specific directory.</p>