Tapio Kauranen

JavaScript SEO for websites

How Google and AI see your pages.

Google can run JavaScript, but it does so with a delay and on its own terms. Many AI bots don’t run it at all. If your page’s content is created only in the browser, search engines can miss part of it.

In short, this is how you optimize a JavaScript or single-page app (SPA) site for search engines:

  • Have the most important content ready in the HTML, with server-side rendering or static pages.
  • Make links ordinary <a href> links.
  • Give every view its own address without the # character.
  • Write the title, canonical address and robots tag into the HTML.
  • Return code 404 for a missing page, not 200.

This guide shows how Google handles a JavaScript page, what the most common problems are and how to test your own site. Each section has a demo that lets you try the point yourself.

Does your site not show on Google at all? Read also Why Google isn’t indexing your page.

What my clients say

In my clients’ own words.

We started working with Tapio on a few different companies some months ago. In a short time, both websites have seen a clear rise in visitor numbers and in the sites’ authority, and the results of paid advertising have clearly improved since Tapio started managing that too.

Website development, SEO and GEO work is excellent, and all of these are included in the monthly package. Tapio’s skills have positively surprised us!

I warmly recommend working with Tapio if you want a skilled professional who is also pleasant and easy to work with.

Eero Järvenpää
Eero Järvenpää, Domio and Pulse Talotekniikka Google review, translated from Finnish · SEO, blogs and Google Ads

Tapio has taken good care of our company’s website for several years now. The cooperation has gone well from the very start, and I can warmly recommend Tapio.

Tapio has very strong expertise in search engine optimization, and working with Tapio is genuinely enjoyable. I especially appreciate how rock-solid professional skill is combined with a straightforward, approachable personality. Strong recommendation!

Very helpful. After following his recommendations, my website started ranking on the first and second page of Google. He also helped me with Google Ads, and I finally started getting some good quality leads.

Barbara Skrodzka
Barbara Skrodzka, cremaypomadastore.com Google review · SEO and Google Ads

Read the reviews on Google Maps

How does Google index a JavaScript page?

Google processes a JavaScript page in three stages. This is how Google describes them in its documentation:

  1. Crawling. Googlebot fetches the page’s HTML and picks up the links that have an href address.
  2. Rendering. The page waits in a queue. When Google has the resources, a Chromium browser runs the page’s JavaScript. Google says the page may stay in the queue for a few seconds or longer.
  3. Indexing. Google reads the text and links from the rendered page and adds the page to the index.

When the content is ready in the HTML, Google sees it in the very first stage. When JavaScript creates the content, it has to wait for rendering. If something goes wrong there, the content is never seen.

Only pages that answer with code 200 get into the render queue. If the page’s HTML has a noindex, Google may skip rendering altogether.

Run the demo: the same price list in HTML and with JavaScript, through Googlebot’s eyes.

Googlebot and a JavaScript page

Content with JavaScript

<title>Kampaamo Kulma</title>

<div id="app"></div>

<script src="/app.js"></script>

  1. Fetch Done Googlebot fetches the page’s HTML and picks up its links. The HTML holds only an empty app container: no text, no links.
  2. Render queue Done The page waits its turn until Google has the resources. Waits in the queue: a few seconds or longer, according to Google.
  3. Rendering Done A Chromium browser runs the page’s JavaScript. The text and 4 links were found only now.
  4. Index Done Google reads the rendered page and adds it to the index. The price page is in the index if rendering succeeded.

Result Visible with a delay

The text and links of a JavaScript page wait for rendering. If the JavaScript crashes, Google doesn’t see them at all, and bots that don’t run JavaScript never see them.

CSR, SSR or static: what is in the first HTML?

The most important question in JavaScript SEO is where the page’s HTML is built. There are three options:

  • Client-side rendering (CSR). The server sends an almost empty page, and the browser builds the content with JavaScript. This is how a typical single-page app (SPA) works.
  • Server-side rendering (SSR). The server builds finished HTML for every request, and JavaScript brings the page to life only after that.
  • Static site generation (SSG). The HTML is built in advance, when the site is published.

Google recommends server-side rendering or pre-built HTML, because it makes the page faster for users and crawlers, and not all bots can run JavaScript.

Dynamic rendering, where bots get a different version from people, is something Google calls a workaround and not a long-term solution. Instead, Google advises server-side rendering, static rendering or hydration.

That is why SPA optimization usually starts with building the important pages on the server or in advance. Next.js, Nuxt and Astro, for example, can do both.

Try the demo: switch the rendering method and see what is in the first HTML.

What is in the first HTML?

Client-side rendering (CSR): first HTML

<head>

<title>Kampaamo Kulma</title>

</head>

<body>

<div id="app"></div>

<script src="/app.js"></script>

</body>

Server-side rendering (SSR): first HTML

<head>

<title>Prices – Kampaamo Kulma</title>

</head>

<body>

<h1>Prices</h1>

<li>Men’s haircut €29</li>

<li>Women’s haircut €39–49</li>

<li>Children’s haircut (under 12) €29</li>

<script src="/app.js"></script>

</body>

Static page (SSG): first HTML

<head>

<title>Prices – Kampaamo Kulma</title>

</head>

<body>

<h1>Prices</h1>

<li>Men’s haircut €29</li>

<li>Women’s haircut €39–49</li>

<li>Children’s haircut (under 12) €29</li>

<script src="/app.js"></script>

</body>

In the browser: the same with all three methods

Kampaamo Kulma

Prices

  • Men’s haircut €29
  • Women’s haircut €39–49
  • Children’s haircut (under 12) €29

In the browser the page looks the same whichever method is used.

Client-side rendering (CSR)

  • Googlebot Sees the prices only after rendering
  • AI bots Don’t see the prices
  • HTML is built In the browser, every time

Problems and fixes

The most common JavaScript SEO problems

When a JavaScript site doesn’t show on Google, the reason is usually one of these six. Most fixes are small code changes once you know what to look for.

The map shows at which stage each problem cuts off the page’s journey to search results or to an AI answer.

Where does a JavaScript page’s journey break?
  1. Fetch Googlebot fetches the page and follows its links. 1 4
  2. Rendering Chromium runs the JavaScript but doesn’t scroll or click. 3
  3. Index Google uses the rendered page to decide whether to add it to the index. 2 5
  4. AI answer AI bots read only the HTML the server sends. 6
  1. 1 Links Google doesn’t follow
  2. 2 Title, canonical and noindex
  3. 3 Lazy loading and infinite scroll
  4. 4 Hash routes
  5. 5 Soft 404 errors
  6. 6 AI bots

2. Title, canonical and noindex with JavaScript

Many JavaScript apps change the page title and metadata only in the browser. Google accepts part of this, but not all of it:

  • Title and description. Google reads a title and meta description set with JavaScript from the rendered page. Bots that don’t run JavaScript see only the HTML version.
  • Canonical address. Google doesn’t recommend setting it with JavaScript. If you do, use the same address as in the HTML, or leave the canonical out of the HTML entirely.
  • noindex. If the first HTML has a noindex, Google may skip rendering, and JavaScript never gets to remove it. Don’t put a noindex in the page’s original code if you want the page in the index.

The safest way is to write all three into the HTML the server sends.

Try the demo: compare the first HTML with the page after JavaScript in three cases.

The head section before and after JavaScript

Title

First HTML

<head>

<title>Kampaamo Kulma</title>

</head>

After JavaScript

<head>

<title>Prices – Kampaamo Kulma</title>

<meta name="description" content="Haircuts from €29.">

</head>

Google Works in Google

Google reads a title and description set with JavaScript from the rendered page. Bots that don’t run JavaScript see only the generic title.

Canonical

First HTML

<head>

<link rel="canonical" href="https://kampaamokulma.fi/">

</head>

After JavaScript

<head>

<link rel="canonical" href="https://kampaamokulma.fi/prices/">

</head>

Google Conflict

The HTML says the page’s primary address is the front page, and JavaScript changes it to the price page. Google doesn’t recommend changing the canonical address with JavaScript: it should be the same as in the HTML.

noindex

First HTML

<head>

<meta name="robots" content="noindex">

</head>

After JavaScript

<head>

<meta name="robots" content="noindex">

</head>

Google Not indexed

When Google sees a noindex in the first HTML, it may skip rendering. Removing it with JavaScript then comes too late, and the page doesn’t get into the index.

3. Lazy loading and infinite scroll

Lazy loading loads images and content only when they are needed. It makes the page faster, but one thing to remember: Google doesn’t scroll the page or click its buttons.

If posts, products or reviews load only on scrolling or from a “Show more” button, Google doesn’t see them. Google’s guidance advises the following:

  • Load content based on whether it is visible, for example with IntersectionObserver, not on scroll or click events.
  • Use the browser’s native lazy loading for images (loading="lazy").
  • Give each part of an infinite scroll its own permanent address, such as /blog/page/2/, and link the parts to each other.
  • Update the address bar with the History API when a new part loads.

Try the demo: switch between a person’s view and Googlebot’s view.

What does Googlebot see of a blog?

Kampaamo Kulma

Blog

  • How often should you get a haircut? not loaded
  • Coloring at home or at the salon? not loaded
  • A child’s first haircut not loaded

<a href="/blog/page/2/">Next page</a>

Content below this point loads only when you scroll kampaamokulma.fi/blog/page/2/

  • Shaping your beard at home not loaded
  • Winter hair care not loaded
  • What should you tell your hairdresser? not loaded

<a href="/blog/page/3/">Next page</a>

Content below this point loads only when you scroll kampaamokulma.fi/blog/page/3/

  • Curly hair: cut and care not loaded
  • A party hairstyle without stress not loaded
  • Why does hair get static? not loaded

Posts found 3/9 posts

Googlebot doesn’t scroll the page, so it sees only the first three posts. Six stay out of the index.

4. Hash routes: #/prices is not a page of its own

Some single-page apps change views with the part of the address after the # character, for example kampaamokulma.fi/#/prices. The browser doesn’t send the part after the # to the server, and Google generally doesn’t support it.

Then the prices, services and contact details get no address of their own, and they can’t show in search results as separate pages.

The fix is the History API, which Google also recommends: every view has an ordinary address, such as /prices/. Also make sure the address works when opened directly: the server has to return the page, not an error.

Try the demo: click the app’s menu and see which addresses Google gets.

Which addresses does Google see?

Prices

Addresses Google gets 1 page

  • kampaamokulma.fi/
  • kampaamokulma.fi/#/services kampaamokulma.fi/
  • kampaamokulma.fi/#/prices kampaamokulma.fi/
  • kampaamokulma.fi/#/contact kampaamokulma.fi/

The browser doesn’t send the part after the # character to the server, and Google generally doesn’t support it. To Google, all four views are one and the same address.

5. Soft 404: an error page that answers “200 OK”

The server of a single-page app often answers every address with the same page and code 200. If the address doesn’t exist, the app shows “Page not found”, but the server has already told Google that all is well.

Google marks such a page as a soft 404 in Search Console. In Google’s Finnish help the status is called “404-uudelleenohjaus”.

Google advises two fixes:

  • Redirect with JavaScript to an address that the server answers with code 404.
  • Add <meta name="robots" content="noindex"> to the error page with JavaScript.

On a server-rendered or static site, the server can answer with code 404 directly.

Try the demo: the same missing page without a fix and with the two fixes.

A missing page that answers “200 OK”

Kampaamo Kulma

Oops, page not found

This service is no longer offered. See all our services.

No fix

Server response

GET /services/perm/

HTTP/1.1 200 OK

Search Console

Soft 404 In the Page indexing report

The server says “200 OK”, but the page says it doesn’t exist. Google marks it as a soft 404 error.

Redirect to a 404 page

Server response

GET /services/perm/

HTTP/1.1 200 OK → JavaScript redirects

GET /404/

HTTP/1.1 404 Not Found

Search Console

Not found (404) In the Page indexing report

Google gets the right answer: there is no such page. A removed page doesn’t belong in the index.

const service = services.find((item) => item.path === location.pathname);
if (!service) {
  // No such service: redirect to an address the server answers with code 404.
  window.location.href = '/404/';
}

noindex

Server response

GET /services/perm/

HTTP/1.1 200 OK

+ <meta name="robots" content="noindex">

Search Console

URL marked ‘noindex’ In the Page indexing report

The error page stays out of the index. Google reads the noindex from the rendered page.

const service = services.find((item) => item.path === location.pathname);
if (!service) {
  // No such service: tell search engines not to index the error page.
  const robots = document.createElement('meta');
  robots.name = 'robots';
  robots.content = 'noindex';
  document.head.appendChild(robots);
}

6. AI bots don’t run JavaScript

ChatGPT, Claude and Perplexity fetch pages with their own bots. In a study by Vercel and MERJ (December 2024), none of them ran JavaScript: they read only the HTML the server sends.

In the study, only Googlebot, which Gemini also uses, and Apple’s AppleBot ran JavaScript. The ChatGPT and Claude bots did fetch JavaScript files, but they didn’t run them.

The volumes are not small: on Vercel’s network, GPTBot made 569 million requests in a month and Claude’s bot 370 million. The corresponding figure for Googlebot was 4.5 billion.

If your price list or service description is created with JavaScript, AI doesn’t see it and can’t recommend you on the basis of it. Read more in the AI optimization guide.

Try the demo: change how the price list is built and see which bots see the prices.

Who sees the price list?

Bot and requests per month

  • Googlebot ✓ Sees the prices Google, including Gemini · runs JavaScript 4.5 bn
  • GPTBot ✕ Doesn’t see the prices OpenAI (ChatGPT) · doesn’t run JavaScript 569 million
  • ClaudeBot ✕ Doesn’t see the prices Anthropic (Claude) · doesn’t run JavaScript 370 million
  • AppleBot ✓ Sees the prices Apple · runs JavaScript 314 million
  • PerplexityBot ✕ Doesn’t see the prices Perplexity · doesn’t run JavaScript 24.4 million

Result 2/5 see the prices

Only the bots that run JavaScript see the prices. The others made a total of about 963 million requests a month on Vercel’s network.

Source: Vercel and MERJ: The rise of the AI crawler (17 December 2024). The request counts are from Vercel’s network over one month. In the study, Meta’s and ByteDance’s bots didn’t run JavaScript either.

How to test whether Google sees your JavaScript content

Always test the finished page, not just the code. Three checks are usually enough:

  1. Source code (Ctrl+U). Shows the first HTML, which is what the server sends. If important text is missing here, JavaScript creates it.
  2. Developer tools (F12). The Elements tab shows the page as the browser built it after JavaScript.
  3. URL Inspection in Search Console. Choose “Test live URL” and then “View tested page”. You see the rendered HTML, a screenshot and the JavaScript console messages.

If the site isn’t yours, Google’s Rich Results Test shows the same rendered page. Google advises using these two tools.

You can paste the code shown in the demo into the browser console on any page. It counts how many words of the page’s text are in the first HTML and how many are in the browser.

Try the tabs in the demo: the same page with three tools.

The same page with three tools

Ctrl+U

<title>Kampaamo Kulma</title>

<body>

<div id="app"></div>

<script src="/app.js"></script>

Ctrl+U Prices missing

The source code shows the first HTML, which is what the server sends. The prices aren’t in it: JavaScript creates them.

F12

<body>

<div id="app">

<h1>Prices</h1>

<li>Men’s haircut €29</li>

<li>Women’s haircut €39–49</li>

<li>Children’s haircut (under 12) €29</li>

</div>

F12 Prices visible

Developer tools show the page as the browser built it after JavaScript. The difference from the source code tells you what JavaScript added.

URL Inspection

<body>

<div id="app">

<h1>Prices</h1>

<li>Men’s haircut €29</li>

<li>Women’s haircut €39–49</li>

<li>Children’s haircut (under 12) €29</li>

</div>

URL Inspection Google saw the prices

The live test shows the HTML as Google rendered it, a screenshot and the JavaScript console messages. If the prices show here, Google sees them.

Compare for yourself: paste into the browser console (F12 → Console)

// Paste into the browser console (F12 → Console) on the page you want to check.
const html = await (await fetch(location.href)).text();
const words = (doc) => {
  const copy = doc.cloneNode(true);
  copy.querySelectorAll('script, style, noscript, template').forEach((el) => el.remove());
  const parts = new Intl.Segmenter('en', { granularity: 'word' }).segment(copy.body.textContent);
  return [...parts].filter((part) => part.isWordLike).length;
};
const first = words(new DOMParser().parseFromString(html, 'text/html'));
const browser = words(document);
console.log('First HTML: ' + first + ' words. In the browser: ' + browser + ' words.');

Example: this site renders its pages on the server

This site, tapiokauranen.com, runs on WordPress. WordPress builds the HTML of each page on the server, so your browser receives a finished page. Between 29 September and 30 November 2026 it was a static Astro site.

That is why the text, headings and links of this guide are already in the first HTML. JavaScript runs only the extras, such as the demos. Google and AI bots get the same text as you.

The meter makes the same comparison for this page as the code in the previous section.

Press the button: the meter fetches this page’s HTML and compares it with what your browser shows.

Measure this page

This page’s content in the first HTML and in the browser
Metric First HTML In the browser
Words of text – –
Links (a href) – –
Headings (h1–h3) – –

In the first HTML –

The meter needs JavaScript. The text of this page still shows, because it is in the HTML the server sends.

JavaScript SEO FAQ

Can Google read JavaScript?

Yes. Google runs the page’s JavaScript in a Chromium browser before it adds the page to the index.

Rendering happens in a queue, though, and Googlebot doesn’t scroll the page or click its buttons. If the JavaScript crashes or loads content only on scrolling, part of the content is missed.

How do I optimize a SPA for search engines?

Have the most important content ready in the HTML, with server-side rendering or static pages. Use a elements with an href address as links, and give every view its own address without the # character.

Write the title, canonical address and robots tag into the HTML, and return code 404 for a missing page. Finally, test with URL Inspection in Search Console.

Do React or Vue hurt SEO?

Not by themselves. What matters is what the server sends. When the app is server-rendered or static, for example with Next.js or Nuxt, the content is in the HTML right away.

An app built only in the browser leaves its content dependent on rendering, and bots that don’t run JavaScript don’t see it.

Do I need dynamic rendering?

No. Google calls dynamic rendering a workaround that is not a long-term solution, and recommends server-side rendering, static rendering or hydration instead.

Do ChatGPT and other AI tools see JavaScript content?

Usually not. In the study by Vercel and MERJ (December 2024), the bots of OpenAI, Anthropic, Meta, ByteDance and Perplexity didn’t run JavaScript. The bots of Google and Apple did.

How long does rendering take?

Google says a page may stay in the render queue for a few seconds or longer. Google doesn’t promise an exact time.

How do I see what Google sees on my site?

With URL Inspection in Search Console: choose Test live URL and then View tested page. You see the rendered HTML, a screenshot and the JavaScript console messages. If the site isn’t yours, use Google’s Rich Results Test.

A technical SEO specialist for JavaScript websites

I do technical SEO as part of the Coding SEO Consultant service.

I find out what Google and AI bots see on your site, which pages are missing from the index and why. Then I fix the causes.

Read more about technical SEO and the SEO audit, or book a free SEO check and we will look at your site together.

Recommended

Coding SEO Consultant

Fixes and SEO every month, and website maintenance and Google Ads for the same price.

€760 /month

Typically 8 hours a month. Price excl. VAT.

  • Search engine optimization
  • AI optimization
  • Website maintenance and development
  • Google Ads
  • A check-in meeting every two weeks
  • No start-up fee
  • Cancel any time

Need only one thing? Custom quote

What I check

  • Indexing check I find out which pages Google has indexed.
  • Index and sitemap I compare the number of pages in Google’s index with the XML sitemap and find out why they differ.
  • Robots meta tags I check that the pages’ robots meta tags don’t stop search engines from reading them.
  • Site structure I make sure all content is within two clicks and no page is left without links.
  • HTTP errors I find error codes such as 404 (page not found) and fix them.

Free SEO check

A 60-minute Google Meet: we look together at how your site shows on Google and what to fix first.

Book a free SEO check

Or email me: tapio@tapiokauranen.com

Examples of results