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

后端 未结 12 974
后悔当初
后悔当初 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:23

    I believe it's better to place script tags just before the closing body tag. Because:

    • Elements are blocked from rendering if they are below the script.
    • In IE6, IE7 resources in the page are blocked from downloading if they are below the script.

    From this article. Also Yahoo's performance rule 6 is Move Scripts to the Bottom

提交回复
热议问题