Why put JavaScript in head

后端 未结 8 1889
被撕碎了的回忆
被撕碎了的回忆 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:53

    The only reason to put JS in the head is for scripts that modify how the browser actually renders the page. For example, Modernizr.js is loaded in the head so that it can do things like add support for HTML5 elements and manipulate classes on the tag before the page begins to render.

    Otherwise, your JS should be going in at the bottom of the page.

提交回复
热议问题