OK, so I'm starting a new project using Rails 3.1, and I'm new to CoffeeScript.
In any case, I like the idea of ββhaving asset files representing the controllers, but what if I want JS to be displayed only when the controller is called?
For example, I have a controller named Game . In my games.js.coffee file I put some code there, and it called for each page request. Even pages that have nothing to do with Games .
In Rails 3.0.7 , what I would like to do is put yield(:js) in the application erb file, and then call content_for(:js) in my Games#action view. Thus, only js was loaded, which was necessary for this controller.
Or am I mistaken about this? Is it better to download and cache ALL js code for each page request to improve performance?
Thanks for any suggestions.
source share