I read here that it is better to include Javascript files at the bottom of the HTML page.
我在这里读到,最好在HTML页面的底部包含Javascript文件。
Why Ruby on Rails doesn't do so by default ?
为什么Ruby on Rails默认不这样做?
1 个解决方案
#1
8
I would guess that Rails includes your application.js
in the <head>
by default because it assumes you'll be minimizing things via the asset pipeline. There's no need to worry about where your script is included if it's a single external file being loaded in parallel by a single HTTP request.
我猜想Rails默认包含你的application.js在中,因为它假设你将通过资产管道最小化事物。如果单个外部文件由单个HTTP请求并行加载,则无需担心脚本的位置。
#1
8
I would guess that Rails includes your application.js
in the <head>
by default because it assumes you'll be minimizing things via the asset pipeline. There's no need to worry about where your script is included if it's a single external file being loaded in parallel by a single HTTP request.
我猜想Rails默认包含你的application.js在中,因为它假设你将通过资产管道最小化事物。如果单个外部文件由单个HTTP请求并行加载,则无需担心脚本的位置。