将脚本放在网页底部会加快页面加载吗? [英] Does putting scripts on the bottom of a web page speed up page load?

查看:191
本文介绍了将脚本放在网页底部会加快页面加载吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

雅虎最佳做法声明将JavaScript文件置于底部可能会使您的网页加载更快。这有什么经历?有什么副作用,如果有的话?

Yahoo best practices states that putting JavaScript files on bottom might make your pages load faster. What is the experience with this? What are the side effects, if any?

推荐答案

它有几个优点:


  • 渲染很快开始。浏览器无法布局尚未收到的元素。这可以避免空白屏幕问题。

  • Rendering begins sooner. The browser cannot layout elements it hasn't received yet. This avoids the "blank white screen" problem.

延迟连接限制。通常您的浏览器不会尝试超过一次连接到同一台服务器的几个连接。如果您有一整套脚本等待从慢速服务器下载,它可能会破坏用户体验,因为您的页面似乎停止了。

Defers connection limits. Usually your browser won't try to make more than a couple of connections to the same server at a time. If you have a whole queue of scripts waiting to be downloaded from a slow server, it can really wreck the user experience as your page appears to grind to a halt.

这篇关于将脚本放在网页底部会加快页面加载吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆