Alaa
Alaa

Reputation: 4631

does inserting javascript code at the beginning of the body affect SEO?


is there any concern of adding javascript code at the very beginning of opening tag of body?
does it affect SEO??

Thanks for your help

Upvotes: 0

Views: 399

Answers (5)

Mo_S
Mo_S

Reputation: 27

It depends which script, it is recommended to put it at the end to increase load times, but if it is a "low weight" script and it is important to you you can put it on the top and check the load time , if you are still in the "green" area then it is OK. If your site will take 0.5 sec longer to load it will not crash all your SEO efforts.

Upvotes: 0

Franz Enzenhofer
Franz Enzenhofer

Reputation: 3816

Yes, because speed is a direct and indirect (via usage metrics) important performance factor for the search engines.

Upvotes: 0

Zachary K
Zachary K

Reputation: 3345

The best place to put it is at the end, as page rendering blocks when loading JS. Mind you that the Google crawler won't care but your users will

Upvotes: 1

jamesmortensen
jamesmortensen

Reputation: 34078

Why don't you put it in the head section so it's all loaded up for you before the page renders? In my experience, the more code you just randomly litter in the body of the HTML page, the more likely there will be conflicts, especially if one subset of JavaScript requires another subset to load or run first.

Of course, if you must put the code in the body, the best place is right before the closing body tag. Sometimes this is necessary.

Upvotes: 1

Samuel Herzog
Samuel Herzog

Reputation: 3611

No, but for reasons of speed I suggest to insert it at the end of the body.

Upvotes: 1

Related Questions