JavaScript SEO Basics: How Google Crawls, Renders and Indexes JavaScript

JavaScript code on a screen

Many modern sites build their pages with JavaScript. Google can process JavaScript, but there are rules that decide whether your content gets seen. This guide follows Google’s JavaScript SEO basics documentation and explains the three phases, the best practices and how to test your pages.

Quick facts

  • Three phases: crawling, rendering and indexing
  • Rendering: all pages with a 200 status code are sent to the rendering queue, where a headless Chromium runs the JavaScript
  • Links: use `<a>` elements with an `href`, and avoid fragment-based URLs such as `#/page`
  • Canonical: set it in HTML; do not use JavaScript to change it to something else
  • Test with: the URL Inspection tool or the Rich Results Test
  • Last checked: 5 November 2026 against Google Search Central

The three phases

Google’s JavaScript SEO basics describe three phases:

1. Crawling: Googlebot fetches URLs from a queue and checks robots.txt first; Google does not render JavaScript from blocked files or on blocked pages

2. Rendering: pages with a 200 HTTP status code are sent to the rendering queue, and a headless Chromium executes the JavaScript

3. Indexing: Google indexes the page using the rendered HTML

Best practices

Links

Use `<a>` elements with an href. Injecting links with JavaScript is fine if they follow crawlable-link practices; see our guide to crawlable links and anchor text. Fragment-based URLs are unreliable, so use the History API with real paths instead.

Titles and descriptions

You can set or change title elements and meta descriptions with JavaScript. See our guide to meta description length for writing them.

Canonical URL

Google recommends setting the canonical in HTML. If you use JavaScript, keep it identical to the original HTML canonical. Google says you should not use JavaScript to change the canonical URL to something else.

Status codes

Return meaningful status codes, such as 404 for missing pages. In client-side routed apps, avoid soft 404s by redirecting to a server 404 URL or adding a noindex robots tag on error views.

Robots meta tags

Be careful with noindex. Google may skip rendering and JavaScript execution when it sees that tag, so removing it with JavaScript may not work. If you want the page indexed, do not include noindex in the original code.

Caching

Googlebot may ignore caching headers, so use content fingerprinting in filenames to avoid stale JavaScript or CSS.

Structured data and lazy loading

You can generate JSON-LD with JavaScript, but test the implementation. Follow Google’s lazy-loading guidelines so images and content remain indexable.

How to test

Use the URL Inspection tool or the Rich Results Test, and check the rendered HTML to confirm that Google sees your content. If a page is not appearing, our guide to checking whether a page is indexed explains the next steps.

Frequently asked questions

Can Google crawl JavaScript?

Yes. Pages with a 200 status are sent to a rendering queue and processed with a headless Chromium.

Should I use fragment URLs?

No. Google says they are unreliable. Use the History API with real paths.

Can JavaScript change my canonical URL?

You should not use JavaScript to change the canonical to something different from the HTML one.

How do I see what Google sees?

Use the URL Inspection tool and look at the rendered HTML.

Scroll to Top