By default js is included in Rails

When you create a new Rails application, it automatically comes with several rather large js files. In the default application layout, they are all loaded onto the page:

<%= javascript_include_tag :defaults %>

I was wondering if all of these javascripts are loading so that the site can slow down?
And if so, where can I change the definition :defaults? Or should I just include the ones I need and delete the line of code mentioned above?

thank

+3
source share
1 answer

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)

Use :defaultsis optional. If you are concerned about performance, you should read at least some of the caching from javascript_include_tagdocs:

+8

Source: https://habr.com/ru/post/1785738/


All Articles