Google's John Mueller: More About Head Section & JavaScript

Jan 16, 2023 - 7:21 am 2 by

Google Head

Last week we reported on a comment made by John Mueller of Google about the head section of your HTML and why you should keep it clean. John, on Friday, posted a Mastodon thread explaining more about the head section and how search engines interact with it, especially if there is a lot of JavaScript in it.

Here is the content from the thread:

SEO in your head vs too much #JavaScript?

This comes up from time to time, I thought I'd be more elaborate once (it's not new). Search engines (I only really know Google, YMMV) render HTML pages and there are some settings that need to be found in the head of a page in order to be valid. If you care about these settings, don't make the brittle, and ideally move those settings to the top of the head.

The SEO settings I'm thinking of are the robots meta tag & the canonical link element, but there's also the title & description meta tag which some people consider important. It's not just about SEO either - you probably also want to make sure things like the character set definition, viewport & CSP are considered valid.

"Of course my head is ok" - sometimes it's not as obvious as clearly broken markup. The head is self-closing, so any HTML element that's not valid in the will result in the rest to be considered as a part of the body. That can be a stray img that ends up somewhere wrong, it could be an iframe that a script injects to the top of the head during rendering. This is visible if you inspect the DOM of a page in your browser.

Browsers are sometimes helpful and try to interpret what you mean, if you don't want a page to be indexed, or want a different URL as canonical, you probably don't want search engines to guess. (SEO is to a large part about not making search engines guess.)

In short, avoid making the head brittle if you care about those SEO settings, consider moving them to the top of the head (don't include 5k lines of JS above them), and double-check the rendered DOM in your browser from time to time.

That is the end of his head thread - got it?

Forum discussion at Mastodon.


Popular Categories

The Pulse of the search community


Search Video Recaps

Google AI Overviews, Ranking Volatility, Web Filter, Google Ads AI Summaries & More - YouTube
Video Details More Videos Subscribe to Videos

Most Recent Articles

Search Forum Recap

Daily Search Forum Recap: May 17, 2024

May 17, 2024 - 4:00 pm
Search Video Recaps

Search News Buzz Video Recap: Google AI Overviews, Ranking Volatility, Web Filter, Google Ads AI Summaries & More

May 17, 2024 - 8:01 am
Google Search Engine Optimization

Remove Your Content From Google's AI Overviews

May 17, 2024 - 7:51 am
Google Ads

Google Ads AI Summaries Live For Some Advertisers

May 17, 2024 - 7:41 am
Google Maps

Order with Google For Food Delivery Going Away End Of June

May 17, 2024 - 7:31 am
Google Search Engine Optimization

Two New Googlebots: GoogleOther-Image & GoogleOther-Video

May 17, 2024 - 7:21 am
Previous Story: Google Business Profiles Attribute Details Beta