JavaScript in <head> or just before </body>?

前端 未结 6 2207
攒了一身酷
攒了一身酷 2020-11-28 06:14

I am about to embark on a new web project and I plan to put some JavaScripts in the and also some before , using the foll

6条回答
  •  心在旅途
    2020-11-28 06:49

    Javascript should be placed at the end of the document so that it doesn't delay the parallel loading of page elements. This does then require that the js is written in a specific way but it does improve the speed of page loads.

    Also, ideally you could host references like this under a different (sub)domain. References to jquery should be pointed to googles CDN too.

    See http://developer.yahoo.com/performance/rules.html for more info.

提交回复
热议问题