title: Rails 3: good rule of thumb for where to put javascript?
body: <p>When writing javascript for a specific page in a site, when do you want to turn the javascript into a function and include it in <code>application.js</code>?</p>
  
  <p>I've seen suggestions <a href="https://stackoverflow.com/questions/602147/javascript-file-per-view-in-rails/602171#602171">about doing this</a> (and minifying or gzip-ing) to minimize HTTP requests.  That makes sense, but what about maintainability?  If I have js code specific to one view, it seems like more work to look into a potentially massive <code>application.js</code>.  That code could be embedded into that view or put in its own <code>.js</code> (or <code>.js.erb</code> or <code>.rjs</code>) file in that view folder.</p>
  
  <p>I've seen another <a href="https://stackoverflow.com/questions/6167805/using-rails-3-1-where-do-you-put-your-page-specific-javascript-code">suggestion</a> that Rails automatically merges all javascript into one file.  Is this true?</p>
  
  <p>TLDR: how much or how little should a developer worry about optimization when writing javascript?</p>