Categories: SEO

Move JavaScript Below HTML Headers

Google’s John Mueller suggests placing JavaScript code below the HTML header tag to ensure search crawlers can fully understand your website.

Mueller shares this advice in a Reddit thread, where a user asks whether HTML code placement could cause SEO issues.

The answer is yes; the placement of HTML code could adversely impact your SEO efforts if it doesn’t appear at the top of the page.

More specifically, it’s important to keep the <head> section of the HTML document at the top of the page. This section should contain the information that Google needs to read your site properly.

Any JavaScript code should be placed below the HTML headers.

To make sure that the JavaScript isn’t interfering with the <head> section, Mueller recommends using the rendering tool in Search Console:

“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.”

Regarding the main content, Mueller says its placement is less important, though it’s crucial for the <head> section to be clean and well-organized so Googlebot can properly understand it.

Mueller continues:

“For the content it doesn’t matter as much, but since the head stuff is for machine-readable information that’s verified to be in a specific part of the page, it really needs to be clean on top.

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

Why Does The Placement Of JavaScript Matter For SEO?

When designing a website, it’s best to include JavaScript code at the bottom of the HTML document near the closing </body> tag.

That’s because JavaScript can delay the rendering of a webpage while it loads, resulting in a poor user experience.

By placing the JavaScript at the bottom of the page, the HTML can be rendered first, allowing the user to view the content while the JavaScript loads in the background.

Additionally, you can prevent external JavaScript files from blocking the rendering of the page using the async or defer attributes.


Source: Reddit

Featured Image: StockEU/Shutterstock

FOLLOW US ON GOOGLE NEWS

 

Read original article here

Denial of responsibility! Search Engine Codex is an automatic aggregator of the all world’s media. In each content, the hyperlink to the primary source is specified. All trademarks belong to their rightful owners, all materials to their authors. If you are the owner of the content and do not want us to publish your materials, please contact us by email – admin@searchenginecodex.com. The content will be deleted within 24 hours.

Share
Chris Barnhart

Leave a Comment
Published by
Chris Barnhart

Recent Posts

Google’s Mueller Outlines Path To Recovery For Sites Hit By Core Update

Google’s Search Advocate John Mueller recently addressed the SEO community’s concerns about site recovery after…

May 7, 2024

Daily Search Forum Recap: May 6, 2024

Here is a recap of what happened in the search forums today, through the eyes…

May 7, 2024

Google Confirms Site Reputation Abuse Update

Google’s SearchLiaison confirmed that Google’s site reputation abuse update started on Monday May 6th. Many…

May 7, 2024

How To Write High-Ranking Content in 2024

This post was sponsored by Fiverr Pro. The opinions expressed in this article are the…

May 7, 2024

Apple’s “Intelligent Search” Will Summarize Webpages

A report based on independently verified accounts notes that Apple’s Safari 18 will come with…

May 6, 2024

46 Blogging Statistics to Know in 2024

Looking to increase the impact of your blogging strategy? Wondering what separates the top blogs…

May 6, 2024