【JS】放html页面head里还是整个页面的最下面</body>下面

Optimize Javascript Placement

Place your javascript at the end of your HTML file if possible. Notice how Google analytics and other stat tracking software wants to be right before the closing </body> tag.

This allows the majority of page content (like images, tables, text) to be loaded and rendered first. The user sees content loading, so the page looks responsive. At this point, the heavy javascripts can begin loading near the end.

I used to have all my javascript crammed into the <head> section, but this was unnecessary. Only core files that are absolutely needed in the beginning of the page load should be there. The rest, like cool menu effects, transitions, etc. can be loaded later. You want the page to appear responsive (i.e., something is loading) up front.

 

原生js库放在head里,其他都放在最底下,保证用户点击页面是有响应的 

 

posted @ 2016-06-27 14:28  阿玛  阅读(242)  评论(0)    收藏  举报