Rails' built-in Javascript view helpers are excellent in terms of convenience, but they make it difficult to follow Yahoo's wise advice that scripts at the bottom of the page make for faster loading pages than scripts at the top of the page (obviously, using inline Javascript like the Rails helpers do requires that your <%= javascript_include_tag :defaults %> be above the main yield in the template.
The solution to this problem is simple. Every time you need to call a Javascript helper method in a view, just wrap it in a <% content_for :footer do %> block, then put a <%= yield :footer > just before the </body> in your template.

tagged with: 