Where should I declare JavaScript files used in my page? In <head></head> or near </body>?

后端 未结 12 968
后悔当初
后悔当初 2020-11-27 15:07

I was reading a tutorial and the author mentioned to include Javascript files near closing body tag () in HTML.

I was wonderi

12条回答
  •  被撕碎了的回忆
    2020-11-27 15:46

    Script tags should generally be in the head section. The exceptions are when they do significant immediate processing that should be delayed until as late as possible in the page load to avoid interfering with the page coming up, as with Google Analytics, or when the script tag's actual placement is a part of its behavior.

提交回复
热议问题