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

前端 未结 8 854
别跟我提以往
别跟我提以往 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:49

    One side effect would be that some scripts doesn't work at all if you put them at the end of the page. If there is a script running while the page is rendered (quite commmon for ad scripts for example) that relies on a function in another script, that script has to be loaded first.

    Also, saying that the page loads faster is not the exact truth. What it really does is loading the visual elements of the page earlier so that it seems like your page is loading faster. The total time to load all components of the page is still the same.

提交回复
热议问题