Put Scripts at the Bottom .
2012-07-12 09:23
465 查看
Best Practices for Speeding Up Your Web Site
The problem caused by scripts is that they block parallel downloads. The HTTP/1.1 specification suggests that browsers download no more than two components in parallel per hostname. If you serve your images from multiple hostnames, you can get more than two
downloads to occur in parallel. While a script is downloading, however, the browser won't start any other downloads, even on different hostnames.
In some situations it's not easy to move scripts to the bottom. If, for example, the script uses document.write to insert part of the page's content, it can't be moved lower in the page. There might also be scoping issues. In many cases, there are ways to workaround
these situations.
An alternative suggestion that often comes up is to use deferred scripts. The DEFER attribute indicates that the script does not contain document.write, and is a clue to browsers that they can continue rendering. Unfortunately, Firefox doesn't support the DEFER
attribute. In Internet Explorer, the script may be deferred, but not as much as desired. If a script can be deferred, it can also be moved to the bottom of the page. That will make your web pages load faster.
The problem caused by scripts is that they block parallel downloads. The HTTP/1.1 specification suggests that browsers download no more than two components in parallel per hostname. If you serve your images from multiple hostnames, you can get more than two
downloads to occur in parallel. While a script is downloading, however, the browser won't start any other downloads, even on different hostnames.
In some situations it's not easy to move scripts to the bottom. If, for example, the script uses document.write to insert part of the page's content, it can't be moved lower in the page. There might also be scoping issues. In many cases, there are ways to workaround
these situations.
An alternative suggestion that often comes up is to use deferred scripts. The DEFER attribute indicates that the script does not contain document.write, and is a clue to browsers that they can continue rendering. Unfortunately, Firefox doesn't support the DEFER
attribute. In Internet Explorer, the script may be deferred, but not as much as desired. If a script can be deferred, it can also be moved to the bottom of the page. That will make your web pages load faster.
相关文章推荐
- Rule 6: Put Scripts at the Bottom(Chapter 6 of High performance Web Sites)
- Put Scripts at the Bottom
- Put a Submit Button At the Bottom of a Survey
- css footer not displaying at the bottom of the page
- -foot-at-bottom-of-the-page
- Rule 5: Put Stylesheets at the Top(Chapter 5 of High performance Web Sites)
- Why do you need to put #!/bin/bash at the beginning of a script file?
- Keep your footer show at the bottom of the page
- Android: Tabs at the bottom with FragmentTabHost
- 构建高性能网站的14条法则:Put Stylesheets at the Top
- Customize UINavigationBar and remove drop shadow at the bottom of UINavigationBar
- [论文笔记] MobileWorks: A Mobile Crowdsourcing Platform for Workers at the Bottom of the Pyramid (Human Computation, 2011)
- [JavaScript]让footer总是停留在页面的底部(footer all the way at the bottom of the page)
- OpenAirInterface USRP安装时You do not have write permissions at the install location问题解决方案
- ESX4.0 host boot stops at the error: VSD mount/Bin/SH:cant access TTY job control turned off
- qt: The build directory needs to be at the same level as the source directory.
- 系统成功的关键The Bottom Line
- The notes of How We Test Software At Microsoft(3)
- The first one blog(nothing at all)
- Error code at the Distributed Transaction Coordinator service in XP