Does putting scripts on the bottom of a web page speed up page load?

前端 未结 8 852
别跟我提以往
别跟我提以往 2020-12-03 01:30

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? <

8条回答
  •  日久生厌
    2020-12-03 01:38

    It has a couple of advantages:

    • 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.

提交回复
热议问题