0

Possible Duplicate:
Where is the best place to put <script> tags in HTML markup?

I have been studying javascript for quite sometime now, and one of my main concerns are am I learning the proper practice, I've asked different people regarding this but They seem to give me pretty vague answers, I know External stylesheet should be placed inside the head tag but when it comes to Javascript? should I put my external javascript in the head tag? or in the bottom of body tag(before the ending tag)?

Community
  • 1
  • 1
user962206
  • 15,637
  • 61
  • 177
  • 270

1 Answers1

0

The simple reason why you should put all <script> nodes at the very bottom of your <body> tag is, that <script> nodes will block the DOM render process and the browsers "UI thread".

In modern browsers you can workaround that issue by indicating attributes like defer and async, but old'ish browsers don't know about those.

jAndy
  • 231,737
  • 57
  • 305
  • 359