Reputation: 719
When creating a new Rails application, it is automatically supplied with several quite large js files. In the application layout, by default, all of them are loaded into the page:
<%= javascript_include_tag :defaults %>
I was wondering, isn't loading all those javascripts can make the site possibly mush slower?
And if so, where can I change the definition of :defaults
? Or should I just include the ones I need and remove the code line mentioned above?
Thank you
Upvotes: 3
Views: 3856
Reputation: 15417
In config/application.rb
# JavaScript files you want as :defaults (application.js is always included).
config.action_view.javascript_expansions[:defaults] = %w(jquery.js rails.js)
Using :defaults
is not mandatory in any way. If you are worried about performance you should read at least the caching part from javascript_include_tag
docs:
Upvotes: 8