Why put JavaScript in head

后端 未结 8 1919
被撕碎了的回忆
被撕碎了的回忆 2020-12-24 11:18

If it is perfectly acceptable to put JavaScript right before what is a good reason to keep it in the ?

Based on t

8条回答
  •  孤独总比滥情好
    2020-12-24 11:32

    If you need the javascript to accomplish something on the page, and you don't want the end user to see the content until that's accomplished, then you should include it in the head. It really depends on each individual case.

    Most of the time, putting it at the bottom really IS better for optimizing page download, as the user will get to see all the content on the page before the JS even starts downloading.

提交回复
热议问题