Does the placement of javascripts at the bottom of html document still gives any loadtime wins, if the site runs on HTTP/2?


The purpose of putting javascript at the bottom was to make sure the document was loaded before letting javascript interact with the web page. Performance had little if anything to do with it.

HTTP/2 has nothing to do with inlined javascript anyway unless you mean you were placing your loading script at the bottom, meaning <script src=""></script>. In that case, you are actually losing performance by not letting the browser jump on downloading the script right away by putting it in the <head>.

|improve this answer|||||
  • as i understand this issue: javascripts block browser at document parsing, if placed in the head. And the question is rather about: HTTP/2 has afaik an ability to priorize ressource download by its own. If javascripts are placed in the head would they still block parsing? - HTTP/2 could eventually priorize them lower and download after the html document, so they no longer block parsing? – Evgeniy May 16 '17 at 7:58
  • @Evgeniy Downloading javascript will block HTML parsing but you can add the defer attribute to <script> or dynamically insert the <script> but this is all off topic here. See this for more info: calendar.perfplanet.com/2016/prefer-defer-over-async – Rob May 16 '17 at 9:56
  • thanks, i know about deferring/async. The question is: whether is it needed if driving HTTP/2? – Evgeniy May 18 '17 at 10:58
  • Your question was about load time. defer doesn't block downloads. H2 has nothing to do with it. – Rob May 18 '17 at 11:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.