I posted an issue about this
( https://github.com/rails/rails/issues/17457#issuecomment-61292491 ) but
I'll copy/paste here for discussion convenience:
I feel like I'm the boy telling the emperor he has no clothes, but here
goes...
Every large rails project that I've worked on has had it's application
javascript grow and grow because everybody leaves 'require_tree .' in
application.js. Personally I hate it and remove it whenever I can (it's
harder on legacy projects), but we should be loading javascript in a saner,
more modular way.
Very often I automagically include javascript files for controllers and
actions if they exist. Here's an example of a helper that I've recently
written (it's not neccessarily pretty, but you get the idea:
def action_and_controller_javascript_include_tag
capture do
concat javascript_include_tag controller_name if
Rails.root.join("app/assets/javascripts/#{controller_name}.coffee").exist?
concat javascript_include_tag
"#{controller_name}/#{action_name}" if
Rails.root.join("app/assets/javascripts/#{controller_name}/#{action_name}.coffee").exist?
end
end
I'd be fine if that were a gem, though rails already generates controller
js files so it might make sense still.
But seriously, can we please encourage not loading all of the javascript
for the entire application?
--
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Core" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to rubyonrails-core+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-core@googlegroups.com.
Visit this group at http://groups.google.com/group/rubyonrails-core.
For more options, visit https://groups.google.com/d/optout.