John Smith
John Smith

Reputation: 8811

Should I include scripts in the head tag or at the end of the document?

I am conflicted between having my site validate as XHTML strict with my scripts in the head or including them at the bottom for faster page loads. What would SO do?

Upvotes: 1

Views: 115

Answers (2)

Jquery Sage
Jquery Sage

Reputation: 1113

Putting scripts at the bottom is the way to go if you want to keep visitors on your site,

it's because a visitor will go away if they don't see anything happening and putting scripts at the bottom makes an illusion of faster loading

Upvotes: 1

user578895
user578895

Reputation:

XHTML validation doesn't matter unless you need your site to validate for some reason (e.g. you're reading it with an XML reader).

Putting JS at the bottom speeds up loading in many cases, and is the way to go unless you need to do something before the page is fully loaded.

Upvotes: 1

Related Questions