Google’s John Mueller suggests protecting the <head> HTML component part “clean” to make sure search crawlers can totally perceive your web site.
Mueller shares this recommendation in a Reddit thread, the place a consumer asks whether or not HTML code placement might trigger search engine optimization points.
The reply is sure; the position of HTML code might adversely impression your search engine optimization efforts if it doesn’t seem on the prime of the web page.
A Notice About Mueller’s Remarks
John Mueller makes use of the time period HTML Headers. However the <head> component isn’t ordinarily referred to that means.
- HTML Headers are typically understood (as casual jargon) to reference the <heading> component (H1, H2, H3, and many others.).
- Header Elements are a selected HTML component often known as <header>, which incorporates the menu, emblem, and many others .
- Head HTML component is a bit on the prime of the HTML doc with metadata concerning the doc itself (title, meta description, and many others.).
So when Mueller references “headers” he’s particularly discussing the <head> component.
John Mueller on JavaScript within the Head Element
Mueller’s intention was to emphasize the significance of protecting the <head> part of the HTML doc tidy and uncluttered with scripts that may be positioned elsewhere.
The <head> component ought to solely comprise metadata concerning the doc itself that’s utilized by browsers and serps, which helps serps perceive what the web page is about and supplies information to browsers and serps for rendering the webpage correctly (which implies show it appropriately).
Some JavaScript code that may be positioned after the <head> component ought to go after.
After transferring any JavaScript out of the <head> part, Mueller recommends utilizing the rendering software in Search Console to examine if the web page is rendering appropriately after the transfer.
“The html headers (<head>) should be pretty much on top. I’d move any JS to below the HTML headers, and check with the rendering tool in search console that the JS doesn’t mess up the <head> section.”
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 because the head stuff is for machine-readable data that’s verified to be in a selected a part of the web page, it actually must be clear on prime.
Down with JavaScript! (within the <head>)”
Why Does The Placement Of JavaScript Matter For search engine optimization?
When designing a web site, it’s greatest to make the most of the async and defer attributes in a strategic method that enables one of the best rendering and interactivity on the quickest web page velocity for customers.
That’s as a result of JavaScript can delay the rendering of a webpage whereas it masses, leading to a poor consumer expertise.
The HTML may be rendered first, permitting the consumer to view the content material whereas the JavaScript masses within the background with the suitable use of the defer and async attributes.
Supply: Reddit
Featured Picture: StockEU/Shutterstock