Move JavaScript Below HTML Headers

[ad_1]

Google’s John Mueller suggests inserting JavaScript code under the HTML header tag to make sure search crawlers can absolutely perceive your web site.

Mueller shares this recommendation in a Reddit thread, the place a consumer asks whether or not HTML code placement may trigger website positioning points.

The reply is sure; the location of HTML code may adversely impression your website positioning efforts if it doesn’t seem on the high of the web page.

Extra particularly, it’s vital to maintain the <head> part of the HTML doc on the high of the web page. This part ought to comprise the knowledge that Google must learn your web site correctly.

Any JavaScript code ought to be positioned under the HTML headers.

To guarantee that the JavaScript isn’t interfering with the <head> part, Mueller recommends utilizing the rendering device in Search Console:

“The html headers (<head>) ought to be just about on high. I’d transfer any JS to under the HTML headers, and verify with the rendering device in search console that the JS doesn’t mess up the <head> part.”

Concerning the principle content material, Mueller says its placement is much less vital, although it’s essential for the <head> part to be clear and well-organized so Googlebot can correctly perceive it.

Mueller continues:

“For the content material it doesn’t matter as a lot, however for the reason that head stuff is for machine-readable info that’s verified to be in a particular a part of the web page, it actually must be clear on high.

Down with JavaScript! (within the <head>)”

Why Does The Placement Of JavaScript Matter For website positioning?

When designing an internet site, it’s finest to incorporate JavaScript code on the backside of the HTML doc close to the closing </physique> tag.

That’s as a result of JavaScript can delay the rendering of a webpage whereas it hundreds, leading to a poor consumer expertise.

By inserting the JavaScript on the backside of the web page, the HTML could be rendered first, permitting the consumer to view the content material whereas the JavaScript hundreds within the background.

Moreover, you possibly can stop exterior JavaScript recordsdata from blocking the rendering of the web page utilizing the async or defer attributes.


Supply: Reddit

Featured Picture: StockEU/Shutterstock



[ad_2]

Scroll to Top