A glowing blue android in profile under a starry sky
Willis Web Design / 01 of 08

Home / SEO Tips / JavaScript SEO

SEO Tips

JavaScript SEO: Make Sure Google Sees Your Content

JavaScript SEO is about making sure Google can see the content your scripts put on the page. Google runs JavaScript, but with limits, and a small slip can hide text, links or whole pages. This guide explains how Google renders scripts, the rules for titles, canonicals and status codes, safe lazy loading, and how to test.

How Google Crawls, Renders And Indexes JavaScript

JavaScript lets a website behave like an app. Making those pages findable in search can bring in new visitors and bring old ones back. Google Search runs JavaScript with an up-to-date version of the Chrome engine, so it can handle most modern code. But it does so in stages, and knowing the stages explains most JavaScript SEO problems.

  1. 01

    Crawling

    Googlebot takes an address from its queue and first checks robots.txt. If the address is blocked, it is skipped, and any JavaScript on blocked files or pages is not run. Otherwise it fetches the page and adds any links in normal href attributes to the queue.

  2. 02

    Waiting To Render

    Every page that returns a 200 success code joins a render queue, unless a robots tag says not to index it. Pages that return an error code may skip rendering. The wait can be seconds or longer.

  3. 03

    Rendering

    A headless copy of Chrome runs the page's scripts. Google then reads links again from the finished page and adds new ones to the crawl queue.

  4. 04

    Indexing

    The rendered page is what Google stores and uses for search. Anything that did not appear after rendering is not indexed.

Traditional pages, and pages rendered on the server, hold all their content in the first response, so they work well. Sites built on the "app shell" model send an almost empty page and fill it with scripts, so Google has to render before it sees anything. That is why Google still recommends server-side rendering or pre-rendering: it is faster for people and crawlers, and not every bot runs JavaScript. Links added to the page by JavaScript are fine, as long as they are proper crawlable links. If you do not want a link followed, mark it nofollow. The wider process is set out in how Google Search works and Googlebot and crawling.

JavaScript SEO In The SEO Tips Map

Every part of the SEO tips, on one map. The page you are reading is highlighted.

Titles, Canonicals And Robots Tags Set By Scripts

Titles And Descriptions

Give every page a unique, descriptive title and meta description so searchers can pick the right result. JavaScript is allowed to set or change both. Our title links and snippets guide explains how Google uses them.

The Canonical Tag

The canonical tag tells Google which address is the main version of a page. The page code itself is the best place for it. If JavaScript touches it, it must set the same address as the original code, never a different one. If you cannot put it in the code, JavaScript may add it, but only if the original code has none. Google does not recommend this route, but it works, because Google reads the tag when it renders. A script might build the address from a clean name and add it to the head:

const link = document.createElement('link');
link.rel = 'canonical';
link.href = 'https://example.com/cats/' + cat.urlFriendlyName;
document.head.appendChild(link);

Make sure there is only ever one canonical tag. Do not add a second or change one that exists. The canonical URLs guide covers the rest.

Robots Meta Tags

A robots tag such as noindex, nofollow stops a page being indexed and its links followed. JavaScript can add or change it, for example to mark a product page as noindex when the product has gone, while telling the visitor it is no longer available. But there is a trap: when Google sees noindex in the original code, it may skip rendering, so a script that removes noindex may never run. If a page should be indexed, keep noindex out of the original code. The meta tags and noindex guide lists every tag.

Status Codes In Single-Page Apps

Google uses HTTP status codes to spot problems. Send meaningful ones: an error code for a missing page, 401 for a page behind a login, and redirect codes when a page has moved so Google can update its index.

Single-page apps, where scripts handle every address in the browser, find this hard. The server often answers every address with a 200 success code, even when the script then tells the visitor the item has gone. Google calls this a soft 404, and it can lead to empty error pages being indexed. Google offers two fixes, and you can use either or both:

Redirect To A Real Error Address

If the item does not exist, send the visitor to an address where the server returns a genuine error code:

if (!product.exists) {
  window.location.href = '/item-gone';
}

Add A Noindex Tag

Or add a robots noindex tag to the error view, assuming no other robots tag is on the page:

const meta = document.createElement('meta');
meta.name = 'robots';
meta.content = 'noindex';
document.head.appendChild(meta);

A static site does not have this problem, because the server knows which pages exist. Every site I build returns a proper error code for missing addresses, which is one of the checks in the website launch checklist.

Google only finds links that are <a> elements with an href. Buttons and click handlers on other elements are not followed. Some single-page apps also use hash fragments, such as /#/products, to show different content. Google cannot rely on these. The old AJAX crawling scheme that once supported them was dropped in 2015.

Use the History API instead, so each view has a real address:

<a href="https://example.com/products">Our products</a>

link.addEventListener('click', (event) => {
  event.preventDefault();
  loadContent(link.href);
  history.pushState({}, '', link.href);
});

The link works as a normal link for Google, while the script loads the content smoothly for visitors and updates the address bar. Our URL structure and links guide covers what makes a link crawlable.

Code Googlebot Can Run: Features, Caching And Components

Google's renderer supports most, but not all, browser features. Google's checklist:

Detect Features And Fall Back

Not every browser feature is supported, and some are switched off. Check for a feature before using it, and provide a fallback or polyfill. Some features cannot be polyfilled, so check each one's limits. Google's example: WebGL photo effects do not work for Googlebot, so skip them or render them on the server.

Expect Permission Requests To Fail

Googlebot declines requests such as camera access, and so do many people. Never make content depend on a permission being granted.

Do Not Rely On Stored Data

The renderer loads each address fresh. Local storage, session storage and cookies are cleared between page loads, so content must not depend on them.

Use Plain HTTP For Content

Googlebot fetches over normal HTTP and does not support WebSockets or WebRTC. Provide an HTTP fallback and handle errors well.

Fingerprint File Names

Googlebot caches heavily and may ignore caching headers. Put a hash of the contents in the file name, such as main.2bb85551.js, so each update gets a fresh name.

Make Web Components Render

Google flattens the shadow DOM and light DOM. Only content visible in the rendered page is indexed. Components that do not use a <slot> for their inner content may not render properly.

Structured Data By Script

JavaScript can build JSON-LD structured data and add it to the page. Test it afterwards. See the structured data guide.

Paywalls Done Properly

Some paywalls send the full text and hide it with JavaScript. That does not truly restrict access. Only send the full content once a subscription is confirmed.

Google also notes that Googlebot skips files that do not add to the main content, such as reporting and error requests, so your analytics may not show its visits accurately. Use the Crawl Stats report in Search Console instead, as described in the Search Console guide.

Lazy Loading SEO: Load Content When It Is Visible

Lazy loading delays images, video and other content until a visitor is about to see it. It saves data and speeds pages up, which is why it is part of most website speed work. Done badly, though, it hides content from Google. The core rule: load all relevant content as soon as it enters the screen, without waiting for the visitor to do anything. Google does not scroll, click or type on your page.

Google lists three safe methods:

  • the browser's built-in lazy loading for images and iframes, using loading="lazy";
  • the IntersectionObserver feature, with a polyfill for older browsers;
  • a JavaScript library that loads content as it comes into view.

Do not lazy-load content visitors will see straight away, such as the main image at the top of the page. It delays that content and people notice.

Infinite Scroll That Google Can Follow

Infinite scroll keeps loading more as you scroll, whether that is a long article in chunks or a list of products. To make it indexable, Google asks for five things:

  • Give each chunk its own lasting, unique address.
  • Make each address show the same content every time it loads, using fixed page numbers such as ?page=12.
  • Avoid relative values such as ?date=yesterday, which change over time.
  • Link the pages in order so search engines can find them all. The ecommerce on Google guide covers pagination for shops.
  • When a new chunk becomes the main thing on screen, update the address with the History API so people can refresh, share and link to it.

Testing Lazy Loading

Run the page through the URL Inspection tool in Search Console and check the rendered code. If your image and video addresses appear in the src of the <img> and <video> elements, it works. For phone-specific advice, see the mobile-first indexing guide and image and video SEO.

Dynamic Rendering: A Workaround Google No Longer Recommends

Dynamic rendering means the server spots search engine bots, usually by their user agent, and sends them a pre-built version of the page without JavaScript, while people get the normal script version. It was once used for public content that changed quickly, or that relied on features crawlers did not support. It can be switched on for every page or only some.

Google now says plainly that it was a workaround, not a long-term fix. It adds complexity and server cost. Google points to server-side rendering, static rendering or hydration instead. It also warns that some content may be missing from the rendered page, and that other search engines may ignore JavaScript entirely.

If you do use it, it is not treated as cloaking, as long as bots and people get similar content. Error pages during set-up are handled like any other error. But sending entirely different content, Google's example being a page about cats for visitors and dogs for bots, can count as cloaking under the Google spam policies.

Testing And Fixing JavaScript Problems Step By Step

If you suspect JavaScript is hiding content, Google suggests this order. If you are not sure JavaScript is the cause, start with its general traffic-drop checks in our SEO traffic drop guide.

  1. 01

    See What Google Renders

    Test the address with the Rich Results Test or URL Inspection tool. Both show loaded files, console messages and errors, and the rendered page.

  2. 02

    Log Script Errors

    Optionally, add a global error handler that records errors from visitors and Googlebot and sends them to a log. Some errors, such as parse errors, cannot be caught this way. Never show debugging output to visitors.

  3. 03

    Send The Right Codes

    Redirect missing items to a real error address, or add noindex, as shown above.

  4. 04

    Remove Fragment Routing

    Switch hash-based views to real addresses with the History API.

  5. 05

    Check Features And Permissions

    Add fallbacks for unsupported features, avoid permission walls and stored data, and use HTTP rather than WebSockets.

  6. 06

    Fingerprint Files

    Rename scripts and styles with content hashes so Google never uses stale copies.

  7. 07

    Check Components And Paywalls

    Confirm web components show all content in the rendered page, and paywalled text is only sent after login.

  8. 08

    Test Again

    Re-run the test. A green tick and no errors means it is fixed. If not, ask in the Search Central help community.

Most small business sites never need any of this. I build hand-made static pages where text, links, titles and canonical tags are in the code from the start, as explained in WordPress against static websites. If your current site is script-heavy and struggling in search, start with the free website audit, book a technical SEO audit, or browse the SEO Tips map.

Based on Google Search Central documentation: Understand the JavaScript SEO basics, Fix Search-related JavaScript problems, Fix lazy-loaded content, Dynamic rendering as a workaround. Licensed under CC BY 4.0. Rewritten in plain English by Willis Web Design; last checked 13 October 2026.

Questions

Questions About JavaScript SEO

Can Google read websites built with JavaScript?

Yes. Google runs JavaScript using an up-to-date version of the Chrome engine, so most modern sites can be indexed. But it happens in a second stage, after crawling, and not every search engine or bot runs scripts at all. That is why Google still recommends server-side rendering or pre-rendering, so the main content is in the page code from the start.

What happens when a missing item still sends a success code?

The visitor is told the item has gone, but Google receives a success code, so it may index an empty error page. Single-page apps often do this by accident, because the server answers every address with the same shell. The fix is to redirect to a real error address or add a noindex tag with JavaScript.

Is lazy loading bad for SEO?

No, if it is done properly. Lazy loading saves data and speeds pages up. The risk is content that only loads when someone scrolls, taps or clicks, because Google does not interact with your page. Load content as it enters the screen using the browser's built-in lazy loading or the IntersectionObserver feature, and never lazy-load what visitors see first.

Should I use dynamic rendering?

Google now calls dynamic rendering a workaround, not a long-term fix, and does not recommend it because it adds complexity and cost. It means sending bots a pre-built version of the page while people get the script version. Server-side rendering, static rendering or hydration are the better choices. If you already use it, it is not cloaking as long as the content matches.

Why does Google show old content after I update my scripts?

Googlebot caches files heavily and can ignore your caching headers, so it may keep using an old copy of a script or style sheet. The fix is to put a short fingerprint of the file's contents into its name, such as main.2bb85551.js. Each update then gets a new file name, and Google has to fetch the fresh version.

Do hand-built static websites need JavaScript SEO?

Much less. My hand-built static sites put all the main text, links, titles and canonical tags straight into the page code, so Google sees everything before any script runs. JavaScript is used for small extras. The checks in this guide still matter for features such as lazy-loaded images, but the big risks of app-style sites mostly do not apply.

Next step

See where your website stands, free.

Run a free test of your current site, or call me for a straight answer about what you need.