# Compare initial HTML and rendered DOM

- Check 08.02 · JavaScript and HTML rendering · Critical
- Source: https://checklist-seo-geo.com/en/javascript-html-rendering/compare-initial-html-rendered-dom
- Compare the HTML returned by the server with the DOM after JavaScript using the browser, headless Chrome, Puppeteer or Screaming Frog, and rank the gaps.
- Updated on 2026-11-25
- Licence: CC BY 4.0. Credit “Checklist SEO & GEO” with a link to https://checklist-seo-geo.com/en/javascript-html-rendering/compare-initial-html-rendered-dom.
- Plugin checklist-seo-geo: 1.3.1 · https://github.com/maximegaul/checklist-seo-geo

## In short

The initial HTML is what the server sends; the rendered DOM (Document Object Model) is what the browser displays after running the JavaScript. Comparing the two, template by template, shows what scripts add, change or remove: text, links, title, canonical, robots, structured data. Expected result: a table of gaps per template, in which every critical element present only after rendering is matched with a fix.

## Why it matters

Not all crawlers see the same version of the page:

| Reader | Version read |
| --- | --- |
| Googlebot | initial HTML at crawl time, then the rendered DOM once the page has gone through the rendering queue |
| Bingbot | JavaScript rendering, with limitations at scale according to Bing |
| Generative engine crawlers (OpenAI, Anthropic, Perplexity) | initial HTML only, according to published observations; not documented by the vendors |
| Preview bots (Facebook, LinkedIn, messaging apps) | initial HTML |
| Visitor | rendered DOM |

A gap is therefore not a problem in itself: a view counter or a chat widget can stay on the client side. It becomes a problem when it affects an element a crawler needs. According to Google's documentation, two cases are more serious than the others:

- **Conflicting signals**: a canonical or a robots directive that differs before and after rendering. Google may not run the script that removes a `noindex`, and advises against changing the canonical with JavaScript.
- **Content that exists only after rendering**: it depends on Google's rendering queue, and it is missing for AI crawlers.

## What it improves

- **Prioritization**: you fix the gaps that affect critical elements first, instead of rewriting the whole front end.
- **Consistent signals**: identical title, canonical and robots before and after rendering avoid unexpected choices by Google.
- **Visibility in generative engines**: each piece of content moved back into the initial HTML becomes readable by crawlers that do not run JavaScript. That still does not guarantee any citation.
- **Release testing**: the same test, run again after each deployment, catches a regression before Google does.

## How to check

The quickest test is done in the browser, in a private window:

1. Open the page source (`Ctrl+U`, `Cmd+Option+U` on Mac) and search for a sentence from the main content.
2. Open the developer tools, “Elements” tab, and search for the same sentence (`Ctrl+F` in the panel).

Found in both places: this content passes. Found only in “Elements”: the content is added by JavaScript. Do the same for a menu link, the title and the canonical.

In the browser console, this code counts the real links in the rendered DOM, to compare with the count in the initial HTML:

```js
document.querySelectorAll('a[href]:not([href^="#"]):not([href^="javascript:"])').length
```

## How to implement

### Before you start

List one URL per template and fetch its initial HTML as described in [inspect the initial HTML](https://checklist-seo-geo.com/en/javascript-html-rendering/inspect-initial-html), which also provides the `audit_html.py` script used below. Then capture the render under the same conditions as a crawler: logged-out session, no cookies, no consent given, mobile viewport. The WRS (Web Rendering Service, Google's rendering service) keeps neither cookies nor `localStorage` from one page to the next and declines permission requests.

### With headless Chrome

Chrome can write out the serialized DOM after the scripts have run:

```bash
# Linux
google-chrome --headless --dump-dom https://example.com/ma-page > rendu.html

# macOS
"/Applications/Google Chrome.app/Contents/MacOS/Google Chrome" --headless --dump-dom https://example.com/ma-page > rendu.html
```

Then compare the summaries, then the visible text:

```bash
diff <(python3 audit_html.py initial.html) <(python3 audit_html.py rendu.html)
diff <(python3 audit_html.py initial.html --texte) <(python3 audit_html.py rendu.html --texte) | grep "^>" | head -50
```

The second command lists the lines of text that exist only after rendering. `--dump-dom` captures the page at load time: content requested from an API later on may be missing. For those pages, use Puppeteer.

### With Puppeteer

Puppeteer drives Chrome from Node.js and waits for the network to go quiet before capturing. Install it in a working folder (`npm install puppeteer`), then save `rendu.mjs`:

```js
// Usage: node rendu.mjs https://example.com/ma-page > rendu.html
import puppeteer from 'puppeteer';

const url = process.argv[2];
const browser = await puppeteer.launch();
const page = await browser.newPage();

await page.setViewport({ width: 412, height: 915, isMobile: true });
await page.goto(url, { waitUntil: 'networkidle0', timeout: 60000 });

process.stdout.write(await page.content());
await browser.close();
```

```bash
node rendu.mjs https://example.com/ma-page > rendu.html
```

To audit several templates, loop over a file of URLs:

```bash
while read -r url; do
  nom=$(echo "$url" | sed -E 's#https?://##; s#[/?=&]#_#g')
  curl -s -L "$url" -o "initial_$nom.html"
  node rendu.mjs "$url" > "rendu_$nom.html"
  echo "== $url"
  diff <(python3 audit_html.py "initial_$nom.html") <(python3 audit_html.py "rendu_$nom.html")
done < urls.txt
```

Playwright, which offers the same feature in Python, Node.js, Java and .NET, works too: `page.goto(url, wait_until="networkidle")` then `page.content()`.

### With the developer tools, no code

1. Page source: `Ctrl+A`, copy, paste into an `initial.html` file.
2. “Elements” tab: right-click the `<html>` tag, `Copy > Copy outerHTML`, paste into `rendu.html`.
3. Compare the two files in an editor that can show differences: in VS Code, select both files in the Explorer and choose “Compare Selected” from the context menu.

The copied DOM reflects your browsing (scrolling, clicks, consent): do not touch the page between loading it and copying.

### With Screaming Frog

In JavaScript rendering mode, Screaming Frog compares the two versions itself across the whole site:

1. `Configuration > Spider > Rendering`: choose “JavaScript”.
2. `Configuration > Spider > Extraction`: tick the options to store the HTML and the rendered HTML so you can view them.
3. Run the crawl, then open the “JavaScript” tab. Its filters isolate pages whose content depends on JavaScript, pages whose title is changed by JavaScript (“Page Title Updated by JavaScript”) and pages whose canonical differs between raw and rendered HTML (“Canonical Mismatch”).
4. In the lower panel, “View Source” shows the original HTML and the rendered HTML side by side.

JavaScript rendering is one of the paid licence features; check the current terms on the vendor's website.

### With Search Console

URL Inspection shows the HTML as rendered by Google itself, with blocked resources and JavaScript errors. It is the reference for Google, but it works one page at a time. See [Test rendering in Search Console](https://checklist-seo-geo.com/en/javascript-html-rendering/test-rendering-search-console).

### Deliverable: gap table

Rank each gap according to the element it affects:

| Element | Present only after rendering | Different before and after rendering | Priority |
| --- | --- | --- | --- |
| `meta robots` | critical | critical | 1 |
| canonical | high | critical | 1 |
| Main text, price, availability | high | high | 1 |
| Navigation links, pagination | high | medium | 2 |
| Title, meta description | medium | medium | 2 |
| JSON-LD | medium | medium | 2 |
| Reviews, related content | medium | low | 3 |
| Counters, widgets, ads | low | low | no action |

Completed example:

| Template | Element | Initial HTML | Rendered DOM | Fix | Guide |
| --- | --- | --- | --- | --- | --- |
| Category | product list | empty container | 24 products, 24 links | server-render the list | [SSR/SSG](https://checklist-seo-geo.com/en/javascript-html-rendering/prefer-ssr-ssg-critical-content-if-relevant) |
| Product page | canonical | `/produit?id=12` | `/produits/chaise-oslo` | correct canonical in the server template | [title, description and canonical](https://checklist-seo-geo.com/en/javascript-html-rendering/check-title-description-canonical-after-rendering) |
| Article | “Specifications” tab | missing | present after a click | content in the HTML, hidden with CSS | [without interaction](https://checklist-seo-geo.com/en/javascript-html-rendering/make-content-accessible-without-user-interaction) |
| Home page | menu | 3 links | 60 links | menu rendered on the server | [href links](https://checklist-seo-geo.com/en/javascript-html-rendering/make-links-available-html-href) |

## Common mistakes

- **Comparing with your own logged-in browser**: cookies, consent and session add content that crawlers will never see.
- **Capturing too early**: `--dump-dom` or a script that does not wait misses content loaded afterwards. Wait until network activity has finished.
- **Wanting to move everything to the server**: a gap in a chat widget or a counter is of no interest for SEO.
- **Looking only at text**: a canonical or a `noindex` changed by JavaScript matters more than a missing paragraph.
- **Forgetting mobile**: Google crawls mainly with a smartphone crawler. Capture the render in a mobile viewport; some content is only mounted on desktop.
- **Testing only once**: a theme, plugin or framework update can move content to the client side. Run the comparison again after every major deployment.

## Frequently asked questions

### What is the difference between initial HTML and rendered DOM?

The initial HTML is the server's raw response, visible with curl or the page source. The rendered DOM is the structure of the page after JavaScript has run, visible in the Elements tab of the developer tools. Scripts can add text, links or tags to it, and change or remove them. Google reads both versions; in practice, AI crawlers read only the first.

### Do the initial HTML and the render need to be identical?

No, a gap between initial HTML and render is normal on most sites. What matters is that critical elements are present and identical in both versions: main text, navigation links, title, canonical, robots directives and structured data. Widgets, counters, ads or personalized content can stay generated on the client side with no consequence for SEO.

### Which free tool shows the rendered DOM?

Several free tools show the rendered DOM. Chrome's Elements tab is enough for a single page. Headless Chrome, with the --dump-dom option, writes it to a file in one command. Puppeteer and Playwright automate the capture across a list of URLs. To see Google's own render, Search Console's URL Inspection and the Rich Results Test display the rendered HTML.

### Is a canonical that differs before and after rendering a problem?

Yes, a canonical that changes between initial HTML and render sends conflicting signals. Google advises against changing the canonical with JavaScript and asks, if it is injected, that it be the only one on the page. AI crawlers and other search engines will only see the initial version. Put the right canonical in the server template and remove the script that rewrites it.

## Resources

- [Google Search Central: Understand the JavaScript SEO basics](https://developers.google.com/search/docs/crawling-indexing/javascript/javascript-seo-basics)
- [Google Search Central: Fix Search-related JavaScript problems](https://developers.google.com/search/docs/crawling-indexing/javascript/fix-search-javascript)
- [Chrome for Developers: Chrome Headless command-line reference](https://developer.chrome.com/docs/automation-and-testing/headless-cli)
- [Puppeteer: documentation](https://pptr.dev/)
- [web.dev: Rendering on the Web](https://web.dev/articles/rendering-on-the-web)

Next steps: [Test rendering in Search Console](https://checklist-seo-geo.com/en/javascript-html-rendering/test-rendering-search-console), [Prefer SSR or SSG for critical content](https://checklist-seo-geo.com/en/javascript-html-rendering/prefer-ssr-ssg-critical-content-if-relevant) and [Fix JS and hydration errors](https://checklist-seo-geo.com/en/javascript-html-rendering/fix-js-hydration-errors).
