When do you choose to load your javascript at the bottom of the page instead of the top?

后端 未结 9 1227
渐次进展
渐次进展 2020-12-10 17:15

I have seen JavaScript libraries being loaded at the top and bottom of the page.

I would love to know when to make these choices. All the JavaScript code I\'ve writt

9条回答
  •  渐次进展
    2020-12-10 18:00

    Top: When having JavaScript events function on elements immediately is more important (so if you use a DOM Ready event to load everything, this is the wrong place)

    Bottom: When loading the content is more important

提交回复
热议问题