JavaScript SEO: How Google Crawls, Renders and Indexes JS
JavaScript SEO is the work of making sure search engines can crawl, render and index the content and links that JavaScript produces on your site. Google can run JavaScript, so a React or Vue site isn't doomed. But rendering is a separate step that can happen later than the initial crawl. Content that only exists after rendering, or only after someone clicks, scrolls or logs in, is where indexing usually breaks. This guide covers how Google's pipeline works, where it fails, how to choose a rendering approach, and how to check what Google actually sees in Search Console.
How Google processes a JavaScript page: crawl, render, index
Google handles a JavaScript page in three phases.
- Crawl. Googlebot requests the URL and gets back the initial HTML, the same thing you see with "View page source." It checks robots.txt first, reads that HTML, and pulls out any links it finds in it.
- Render. The page joins a queue for Google's Web Rendering Service, which loads it in a headless, up-to-date version of Chromium. The service runs your JavaScript, fetches your API data and builds the final DOM.
- Index. Google indexes the rendered HTML. It also finds new links in it and sends them back to the crawl queue.
The catch is the gap between steps 1 and 2. Crawling is cheap. Rendering means running a browser, so Google queues it and does it when it has resources. Sometimes that happens quickly and sometimes it takes longer. You can't control the timing, so plan around it.
In practice, anything in the initial HTML gets seen first and most reliably. Anything JavaScript injects later depends on the render going well.
Here's a simple comparison. Say you sell hiking boots.
- Page A sends server HTML that already contains the product name, description, price, breadcrumb links and a
<title>. JavaScript adds a photo carousel and a size picker on top. Google understands the page from the first fetch, and rendering only adds detail. - Page B is a single-page app. The server sends
<div id="app"></div>and a bundle. The bundle fetches/api/products/123and builds everything. Until rendering finishes, Google has an empty shell with no title, no text and no links.
Page B can still get indexed. But every failure point in the next section hits Page B in full and barely touches Page A.
What Googlebot does not do when it renders
Googlebot renders pages. It doesn't use them the way a person does. Most JavaScript indexing problems come from expecting it to act like a visitor. Here's what it skips, what you'll notice, and how to fix each one.
- It doesn't click. Buttons, tabs, accordions and "Show more" links that fetch content on demand never fire. Symptom: the text is missing from the rendered HTML. Fix: put the content in the DOM on page load and use CSS to hide or show it. Tabs and accordions are fine as long as the text is already in the DOM.
- It doesn't scroll. Infinite scroll that loads on a scroll event won't load more for Googlebot. Symptom: only the first batch of items gets indexed, and deeper products or posts are never found. Fix: give each batch its own paginated URL (
?page=2) with a real link to it. - It doesn't keep state. Each page loads fresh, without cookies, local storage or session data carried over from earlier pages. Symptom: content that depends on a stored preference, a consent choice or a "returning visitor" flag doesn't show up. Fix: make sure the default, stateless version of the page includes the content you want indexed.
- It doesn't accept permission prompts. Requests for location, notifications or the camera are declined. Symptom: a store locator that waits for geolocation renders nothing. Fix: show a sensible default, such as a list of locations, before asking for anything.
- It can't fetch what robots.txt blocks. If your JS bundle, CSS or API endpoint is disallowed, the renderer can't load it. Symptom: a blank or broken render, or a page with layout but no data. Fix: allow Googlebot to fetch every script, stylesheet and API path the page needs.
- It gives up on failed requests. If an API call errors out, times out or needs authentication, the content it would have filled in stays missing. Symptom: rendered HTML shows loading spinners or empty containers. Fix: keep APIs fast and stable for bot traffic, and don't rate-limit or block Googlebot on endpoints your pages rely on.
Links and navigation built with JavaScript
Google finds new pages by following links, and it only treats one thing as a reliable link: an <a> element with an href attribute that points to a real URL.
<!-- Google can follow this --> <a href="/pricing">Pricing</a>
<!— Google can’t reliably follow this —> <span onclick=“go(‘pricing’)“>Pricing</span>
The second version works fine for users. To a crawler it’s just text. The same goes for <button> elements used as links, <a> tags with no href or with href=“javascript:void(0)”, and URLs your code builds only when someone clicks. If your router needs a click handler, keep the real href on the anchor and intercept the click. Next.js’s Link, Vue Router’s RouterLink and similar components already do this.
Hash routing vs. the History API
URLs like example.com/#/pricing are a problem because Google generally ignores everything after the #. To a crawler, every “page” in a hash-routed app is the home page. Use the History API (pushState) so each view has a normal path like example.com/pricing, and make sure your server returns the right content when someone requests that path directly. Every modern framework router supports this.
One clean URL per indexable view
Any view you want ranked needs its own URL that loads that view on a fresh request. If a product modal opens on top of a category page without changing the URL, the product has no page Google can index. Change the URL when the content changes in a meaningful way, and make that URL work when loaded cold.
Pagination, “load more” and infinite scroll
The pattern that works for both users and crawlers is a “Load more” button or infinite scroll for people, backed by paginated URLs for crawlers. Each page of results gets its own URL (/boots?page=3), linked with a real <a href>. Update the address bar as people scroll, so the URL always reflects what’s on screen.
Keep sitemaps in sync with your routes
An XML sitemap helps Google find URLs that internal links might miss, and that matters more on JavaScript sites where links can fail. Generate it from the same route definitions or database your app uses, so new pages show up and removed pages drop out. A sitemap full of URLs that return 404 or redirect weakens trust in the whole file.
Common JavaScript SEO problems and how to fix them
These are the issues that show up again and again on JavaScript sites, each with how to spot it and how to fix it.
Content that only appears after interaction
Symptom: reviews, specs or FAQ answers show up for users but aren’t in the rendered HTML in URL Inspection. Fix: load the content with the page and use CSS to collapse it. If it’s long, render a meaningful part server-side and link to a full page for the rest.
Blocked JavaScript, CSS or API resources
Symptom: the URL Inspection screenshot is blank or unstyled, and “page resources” lists files that couldn’t be loaded. Fix: remove the Disallow rules that cover /static/, /assets/, /_next/, /api/ or similar paths. Also check third-party domains you depend on, since their robots.txt applies to their files.
Soft 404s in single-page apps
Symptom: /products/does-not-exist shows a “Not found” message but returns HTTP 200, and Search Console reports soft 404s or indexes junk URLs. A client-side router can’t change the status code the server already sent. Fix: have the server return a real 404 for unknown routes. That’s easy with SSR or with a catch-all that checks the database. If the server truly can’t know, use JavaScript to add <meta name=“robots” content=“noindex”> on the error view, or redirect to a URL that does return 404.
Infinite or duplicate URL states
Symptom: filters, sort orders, tracking parameters and session IDs create thousands of URL variants of the same content, and Google spends its crawling time on them. Fix: decide which filtered views deserve to rank and give those clean, linked URLs. For the rest, point a canonical tag at the main version, keep session IDs out of URLs, and avoid generating crawlable links for every possible filter combination.
Metadata that JavaScript rewrites
Symptom: the raw HTML has one title, canonical or robots meta, and the rendered HTML has another. Which one Google uses isn’t predictable, so you can end up with the wrong canonical or a missing title. Worse, if the initial HTML says noindex, Google may skip rendering entirely, so JavaScript that removes the tag later won’t help. Fix: make the raw and rendered versions match. Set the title, meta description, canonical and robots meta on the server whenever you can.
Hydration errors
Symptom: the server sends complete HTML, but when the client JavaScript “hydrates” it, a mismatch or runtime error wipes the content or replaces it with an error state. Users may see a flash of content followed by a broken page. Google may index the broken version. Fix: watch the browser console for hydration warnings, make sure server and client render from the same data, and add error boundaries so one failing component doesn’t take down the page.
Lazy-loaded images and text that never load
Symptom: images or sections below the fold are missing in the rendered HTML because they wait for a scroll event. Fix: use native loading=“lazy” for images, or an IntersectionObserver-based loader, rather than scroll listeners. Never lazy-load the main content of the page.
Structured data injected by JavaScript
Google can read JSON-LD that JavaScript adds, but for shopping it advises against relying on it. Google’s product snippet documentation says: “If you’re a merchant optimizing for all types of shopping results, we recommend putting Product structured data in the initial HTML for best results.” It adds: “Be aware that dynamically-generated markup can make Shopping crawls less frequent and less reliable, which can be an issue for fast-changing content like product availability and price.” Fix: render Product, Offer and Review markup on the server, keep price and availability in sync with what the page shows, and, as the same documentation puts it, “Validate your code using the Rich Results Test and fix any critical errors.”
Rendering options: client-side, server-side, static, pre-rendering and dynamic rendering
How your pages are rendered decides what Google gets on the first fetch. Here’s how the main approaches compare.
| Approach | What Google gets in the initial HTML | SEO risk | Cost and complexity | Suits |
|---|---|---|---|---|
| Client-side rendering (CSR) | A mostly empty shell plus script tags | Highest: everything depends on rendering | Lowest to build and host | Logged-in dashboards, admin tools, apps that don’t need indexing |
| Server-side rendering (SSR) | Full HTML built on each request | Low, if hydration is clean | Higher: needs a server, caching and monitoring | Large catalogs, marketplaces, data that changes often |
| Static site generation (SSG) | Full HTML built at deploy time | Lowest | Low to host; rebuilds needed when content changes | Blogs, docs, marketing sites, content sites |
| Pre-rendering, hybrid or islands | Full HTML for key pages or regions, with JavaScript only where needed | Low | Medium: you pick per page or per component | Sites that mix static content with interactive parts |
| Dynamic rendering | Pre-rendered HTML for bots, client-rendered app for users | Medium: two versions that can drift apart | Medium to high: a separate rendering service to maintain | A stopgap for legacy CSR apps you can’t rebuild yet |
The default choice is simple: if a page needs to rank, send its content as HTML. SSG for content that changes on publish, SSR or hybrid for content that changes constantly. Keep pure CSR for screens behind a login.
Frameworks as examples, not rankings
Most modern frameworks can do several of these. Next.js (React) and Nuxt (Vue) support SSR, SSG and mixed setups per route. SvelteKit does the same for Svelte. Astro takes an islands approach. Any of them can produce search-friendly pages if you configure them for server or static output, and any of them can produce an empty shell if you don’t.
Is Astro.js good for SEO? For content sites, yes, by design. Astro ships plain HTML by default and only adds JavaScript to components you mark as interactive, so Google gets the full content on the first fetch and pages stay light. It’s less of a natural fit for app-like sites where nearly everything is interactive.
Is dynamic rendering cloaking?
No, as long as bots and users get the same content. Cloaking means showing search engines something different from what people see, to manipulate rankings. Dynamic rendering sends the same content in a different format (pre-built HTML instead of a JavaScript app). It becomes cloaking if the bot version has text, links or offers that users don’t get. Google has also presented dynamic rendering as a workaround rather than a long-term solution, so treat it as a bridge to SSR, SSG or hybrid rendering, not as where you end up.
How to test JavaScript rendering in Google Search Console
You don’t need to guess what Google sees. The URL Inspection tool shows you.
- Inspect the URL. Paste the full URL into the search bar at the top of Search Console. The first view shows what’s in the Google index: whether the page is indexed, the canonical Google picked, and when it was last crawled.
- Run the live test. Click “Test live URL.” This fetches and renders the page now, so you can confirm a fix before Google recrawls.
- Compare live with indexed. If the live test looks right but the indexed version doesn’t, Google may simply not have re-rendered yet. If both look wrong, the problem is on your side.
- Open the rendered HTML. Click “View tested page,” then the HTML tab. Search it (Ctrl+F or Cmd+F) for a sentence from your main content, a few important internal links, your
rel=“canonical”and your robots meta. If it’s not in there, Google doesn’t have it. - Check the screenshot. A blank or half-loaded screenshot points to blocked resources, failing API calls or a JavaScript error.
- Review “More info.” Look at “Page resources” for files that couldn’t be loaded and at “JavaScript console messages” for errors. A blocked bundle or an uncaught exception often explains a missing section.
Other checks worth running
- Rich Results Test. Run it on any page where JavaScript adds structured data. It renders the page and shows which markup Google detects.
- View source vs. DevTools. In Chrome, compare “View page source” (the raw HTML) with the Elements panel (the rendered DOM). Anything only in the Elements panel depends on rendering. Disabling JavaScript in DevTools and reloading gives you a quick look at the worst case.
- Crawl tools in JavaScript mode. Desktop crawlers like Screaming Frog SEO Spider and Sitebulb can crawl once with raw HTML and once with JavaScript rendering. Comparing the two shows which titles, links, canonicals and words appear only after rendering, across the whole site instead of one URL at a time.
- Server logs. Filter for Googlebot (and verify it’s really Google with a reverse DNS lookup). Check that it requests your JS bundles and API endpoints, and look for 4xx or 5xx responses on them. If Googlebot never fetches an API your pages need, or gets errors from it, rendered pages will be missing data.
After that, track indexing over time with the Page indexing report. Watch for jumps in “Crawled, currently not indexed,” “Soft 404” and “Duplicate, Google chose different canonical than user” after a release. Those are often the first sign that a JavaScript change broke something. If you publish with Balzac, it connects to Google Search Console, tracks each article from live to indexed, ranking and cited by AI, and reports clicks per page every Monday.
Checklist before shipping a JavaScript feature
- Every view you want indexed has a unique, clean URL that loads that view on a fresh request.
- Important content and internal links are in the initial HTML, or load reliably on page load without interaction.
- Navigation uses
<a href>links, not click handlers on spans or buttons. - Title, meta description, canonical and robots meta are identical in the raw and rendered HTML.
- Structured data is present and valid, and in the initial HTML where possible (always for Product markup).
- Status codes are correct: 200 for real pages, 301 for moves, real 404s for missing pages.
- JS, CSS and API endpoints aren’t blocked in robots.txt.
- The XML sitemap includes new routes and drops removed ones.
- No indexable content is gated behind clicks, scroll events, logins or permission prompts.
- Performance is in check: heavy bundles slow rendering and hurt Core Web Vitals, so split code and defer what isn’t needed on load.
- The URL Inspection live test passes on a sample of affected pages before and after release.
Do other search engines and AI crawlers render JavaScript?
Don’t assume they do. Not every crawler runs JavaScript the way Googlebot does, and capabilities vary from one engine or AI assistant to another and change over time. Content that only appears through client-side rendering may be invisible to some search engines and to the crawlers behind AI answers, even when Google indexes it fine.
That’s one more reason server-rendered or static HTML is the safer default: it works for any crawler that can read a web page, whether or not it executes scripts. To check that AI crawlers can reach your site at all, Balzac has free tools, including an AI crawler checker and a robots.txt checker.
Where to start: pick your three most important page templates (say, home, a category and a product or article), run each through URL Inspection’s live test, and search the rendered HTML for your main content and links. Whatever’s missing there is your JavaScript SEO to-do list.