What Actually Happens When JavaScript Changes a Page?

“It's in the HTML” can mean two different things. It can mean the server sent it in the document, but it can also mean someone hit inspect element after the page rendered and saw it there. Those are useful observations, but they describe different stages of the same process and if we're investigating missing content, links or indexing instructions it's really important to differentiate between the two.

HTML is a document the browser can change

Your browser parses the HTML sent to it by a server into what's called a Document Object Model, or DOM: a representation of the page that scripts can inspect and modify. MDN explains that interface here.

JavaScript can add a description, replace a title, insert links or, well, pretty much do anything it wants to a page; it's what enables complex web apps to work, and so the DOM of a fully rendered page may therefore differ substantially from the original response.

For an SEO, there are three useful things to keep separate:

Don't assume a crawler experiences all three in exactly the way you do, or even at all.

The SEO of it all

Google can process JavaScript. Its documented pipeline includes fetching, processing and rendering; links can be discovered in the response and again in the rendered HTML. Its JavaScript SEO basics guide covers this bit pretty well, so feel free to read it in their words.

Obviously, that capability is useful, but it creates new (Well they were new in 2015 or something) and exciting things for SEOs to check to ensure Google sees the page we see: scripts must be accessible and executable by Googlebot (no blocking /scripts/ in robots.txt please), required data must arrive, and the final content must be present in the state Google processes, aka without clicking, scrolling, moving a mouse or accepting (or having) cookies.

also remember that Google does not always render JS, and almost every study I have ever seen suggests that Google is slower to index changes made to pages that use JS - it's also very worth remembering that Google doesn't click or scroll when it loads your pages, but we'll get to that in a bit.

So what's the difference?

When Google fetches a page, it gets the HTML your server sends. When it (or any browser) renders that page, it runs JavaScript, which can change what’s there: adding product listings, removing links, replacing text, or building most of the page from scratch.

Fetching is essentially asking for the recipe, rendering is doing the cooking.

This means the HTML in the response and the page after JS runs can be very different, and for SEO, we need to check and understand both - for instance, this example page demonstrates a page that looks absolutely fine when rendered, but to any tool or system that doesn't render or run JS, is blank. This, obviously, is at best, non-optimal: Google will render that content, but less quickly than if it was just in the response, and whether or not an LLM will see it is still a little bit up in the air.

Which brings us to hydration, because even a page that arrives with all its content already in the HTML can change when the app starts up.

Rendering and hydration aren't the same thing, but they are linked

With serverside rendering, the server sends HTML that the browser can display straight away. (if you need an explanation of different types of rendering, may I recommend this article by me from a previous life).

The app’s JavaScript then makes that existing page interactive via hydration; for example, by adding the functionality behind the “Add to basket” button that actually allows a user to add a product to their basket. Imagine the page is one of those wild west towns where it's all facades initially, then the actual buildings get added in afterwards.

However! While Hydration is designed to add functionality to pages that are visibly rendered, it can still break things.

Imagine a server-rendered category page containing product links. The browser starts with those links, but a bug replaces them with an empty list during hydration. Your raw HTML crawl looks healthy, but the rendered crawl doesn't. Problem.

Metadata can be changed as well but please don't

Some applications manage titles, canonicals and robots tags through client-side code.

I really don't like this.

Google's JavaScript guide advises against using JavaScript to change a canonical to a different URL from the one declared in the original HTML. It also warns that an initial noindex can prevent the rendering you were relying on to remove it. Metadata, especially indexation and crawling hints like canonicals and robots tags, should arrive as part of the initial response and remain untouched by JS. There's no need to change them this way and the risk simply isn't worth it.

Remember, Google doesn't interact

An accordion whose text is already present but hidden is different from a button that fetches the text only after somebody presses it.

Google says Search doesn't interact with pages to trigger content loading - check out an example here of a page with links hidden in a menu that simply doesn't exist until the user clicks the button. This is staggeringly common with React sites, and also with vibecoded sites - if you've recently been through a migration/replatform/redesign and you're finding that the pages in your nav aren't getting crawled as much, this may well be why.

However, navs aren't the only place this problem rears its ugly head; any bit of functionality that defaults by obscuring content (hiding/blurring/whatever) may well be doing it. One of the most underrated technical SEO tools in the world is opening a page, not touching anything, then doing a Ctrl+F for something that you know should be there.

And while I'm at it:

Links need to be actual links

JavaScript can create perfectly usable, crawlable links.

Try telling some JS devs that.

Links need to follow Google's link guidance (and the guidance of W3), ie they need to be an anchor ("a" tag) with an href that resolves to a real destination - ideally an absolute url but in 2026 I don't know if anyone is having that argument too strenuously nowadays. Ideally, links would be part of the initial html response, but if you absolutely HAVE to render them with JS, at least use JS to create real actual links.

A practical comparison

You can compare the response and rendered HTML manually, but I'd start with The Gray Dot Company's Rendering Difference Engine. It's a Chrome extension that highlights what's been added, removed or changed during rendering, with separate views for metadata, headings, links, media and page copy.

Open a page and use the extension's Difference tab to see what changed. Then look at the bits that matter for that page: did the main content arrive? Did important links disappear? Did JavaScript change the canonical or robots instructions? You can export the code and page copy to keep a record of what you found.

It is worth remembering though, the extension shows differences in your browser; it doesn't necessarily tell you what Google has indexed.

Comparing Google's HTML with View Source

You can use my HTML comparison tool to compare the source with the HTML shown in Google's URL Inspection tool - I built this a while ago for my own nefarious purposes;Gray Dot's extension is more helpful day to day as it lives permanently in the corner of your browser, but if you use Firefox or have a scenario where you need to measure two html documents that have come from elsewhere, it's useful.

To inspect differences between your server response and what Google has seen:

  1. Open the URL in your browser, choose View Page Source, and copy the HTML into Before.
  2. Inspect the same URL in GSC's URL Inspection tool and either hit "View Crawled Page" (Best), or Test live URL, open View tested page > HTML (Not quite as reliable) and copy that HTML into After.
  3. Hit Compare HTML. Check the SEO elements for changes to titles, canonicals, robots instructions, headings, links and JSON-LD. Use HTML diff for the code or Page text for the extracted copy.

For example, are the category links in View Source still present in Google's tested HTML? Has the canonical changed? Is the main content missing? You can download the comparison to attach to a developer ticket. Everything stays in your browser, data doesn't go anywhere, etc etc.

Check what survives

JavaScript gives us plenty of ways to build a page, and plenty of ways to accidentally make half of it disappear. Follow the important bits: what arrives in the response, what survives rendering, and what Google is actually seeing.

If your product links only exist after somebody opens a menu, or hydration replaces your category page with an empty div, you've got something concrete to investigate. Take that evidence to a developer, reproduce the problem, and check the same things after the fix.