admin管理员组文章数量:1384246
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
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
Share Improve this question asked Jan 16, 2011 at 13:51 hizkihizki 7191 gold badge8 silver badges20 bronze badges1 Answer
Reset to default 8In 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:
- http://apidock./rails/ActionView/Helpers/AssetTagHelper/javascript_include_tag
本文标签: javascriptDefault js included in RailsStack Overflow
版权声明:本文标题:javascript - Default js included in Rails - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744505203a2609553.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论