Sign in through GitHub

Please read for an updated status on RailsCasts:

Learn more or hide this

Raphael Martins's Profile

GitHub User: rafudu

Comments by Raphael Martins

Avatar

I was wondering: to load all the "controller specific" javascripts in the app.js file is really a good idea? I mean, if you have a large application you'll be probably overloading your page with useless traversing, events or conditionals to check wether a script must be executed on this page. I think this is a high price to pay, don't you? You can cache JS files, but you can't cache the execution.

Usually I keep all my libs and global scripts in the app.js file, and if I need any extra JS for a specific request I load a custom file containing just the action's JS. This last file is usually really small, simple and as a side-effect my code gets less prone to conflicts because this script is somewhat isolated from the rest of the application.

I think a "per action" js loading approach would be welcome!