NewVitalSentinel, redesigned
GuideSite HealthRedirects

JavaScript Redirects: Why Google Follows Them Late, or Not at All

A JavaScript redirect returns a 200 and only moves after the page renders. Why Google follows it late or never, why AI assistants miss it, and how to replace it.

Martin Stepanek
Martin Stepanek
December 4, 2026
6 min read
Share

Save one line as old.html: <script>location.replace("/new.html")</script>. Serve the folder with python3 -m http.server 8000. Then run curl -s -o /dev/null -w "%{http_code}" http://localhost:8000/old.html.

It prints 200. Now open the same address in a browser. You land on /new.html.

The server said the page exists. A script said, a moment later, that it moved.

Google can read that script. It does so only after it crawls the page, queues it and renders it. Rendering means running the page's scripts the way a browser does. Any step can be slow, and one can fail. The bots that don't render never see the move at all.

If you only need the code, location.replace in the test above is the form to use.

A JavaScript redirect isn't a redirect until something renders the page.

The server says 200 and the browser goes elsewhere

A normal redirect lives in the HTTP response. The server answers 301 with a Location header, and the browser never needs the body.

A JavaScript redirect lives in the body. The server answers 200 and sends a page. A script inside that page then changes the address.

So it's neither a 301 nor a 302. The status is 200. Whatever the script does happens later.

A public page works the same way. Paste RapidTables' test page, www.rapidtables.com/web/dev/redirect/javascript-redirect-test.html, into the raw vs rendered checker. You see the page twice: once as the server sends it, once after scripts run.

The raw vs rendered checker: the server HTML has 0 words, no title and no H1, the rendered page has 229 words, a title and an H1.The server sends an almost empty page, with 0 words, no title and no H1, until JavaScript runs and brings 229 words, a title and an H1.

The line comparison shows what the server sends: only the redirect script.

A line-by-line comparison: the server HTML holds one script line calling window.location.replace, the rendered side holds 270 lines.The only line in the server HTML is the script that calls window.location.replace, against 270 lines on the rendered side.

Google follows it after rendering

Google's documentation gives the order. Its page on redirects and Google Search (opens in a new tab) says:

Google Search interprets and executes JavaScript using the Web Rendering Service once crawling of the URL has completed.

Google doesn't treat the result as weaker. The same page lists a JavaScript location redirect as permanent. It orders its table "by how likely Google is able to interpret correctly". Server-side redirects sit at the top, meta refresh comes next and JavaScript below that.

The weak point is detection. Google's advice agrees:

Only use JavaScript redirects if you can't do server-side or meta refresh redirects.

How late is late

Rendering has a queue. Google's JavaScript SEO basics (opens in a new tab) says Googlebot "queues all pages with a 200 HTTP status code for rendering". A page "may stay on this queue for a few seconds, but it can take longer than that."

One site has published numbers. In April 2024 Vercel and MERJ matched more than 37,000 pages (opens in a new tab) on nextjs.org against Google's crawls. They measured the gap between crawl and render.

That's one site. The shape still matters: most pages render fast, and a long tail waits for hours.

A chart of render delay percentiles: a median of 10 seconds rising to about 18 hours at the 99th percentile.Vercel and MERJ, 2024, more than 37,000 pages on nextjs.org: median render delay 10 seconds, 99th percentile about 18 hours.

A JavaScript redirect gets discovered when the page is rendered, not when it's crawled. Until then Google still holds the old URL. Multiply that by every old address after a migration.

A diagram: a server-side redirect is seen on the first request, a JavaScript redirect only after crawl, render queue and rendering.A server-side redirect is seen on the first request; a script is seen when the page is rendered.

When Google never follows it

Google's redirect page puts the other half of the title in one sentence:

This means that if you set a JavaScript redirect, Google might never see it if rendering of the content failed.

Rendering can also be skipped on purpose. Google's JavaScript SEO basics says that if the HTTP status code is non-200, "rendering might be skipped". So a script on an error page isn't a redirect.

The Vercel and MERJ data points the same way. Pages with noindex in the initial HTML "were not rendered, regardless of JS content". So did pages with other 3xx, 4xx and 5xx errors. A leftover noindex on the old page should stop the script from running too. The study never tests redirects, so that part is my inference.

Google does recommend one use. A single-page app can't always return a real 404. For that case Google says:

Use a JavaScript redirect to a URL for which the server responds with a 404 HTTP status code.

AI assistants read only the raw HTML

In June 2026 Andre Alpar tested 12 AI assistants (opens in a new tab) on a page whose real value only appeared after a script ran. ChatGPT, Claude, Gemini, Perplexity, Meta AI, Copilot and Grok all answered from the raw HTML.

That was one live test on one site, so check your own logs too. I show how in AI Crawlers on Your Server: More Than One in Four Hits Was Fake, Half Can't Be Checked.

For them the old URL never moves. They read the 200 response and stop. If that response is an empty shell, that's all they know about the address.

MDN says the same about every client. A JavaScript redirect "will only work on clients that execute JavaScript". Link checkers, simple crawlers and preview bots all count.

How to find JavaScript redirects on a site

For one URL, compare two things: the status your server returns, and the address the browser ends on. A 200 that ends somewhere else is a JavaScript redirect.

The raw vs rendered checker does the comparison in one run. It takes one snapshot when the page finishes loading, so a redirect on a timer isn't caught. If a page sends the browser to another domain, it says so and stops, because there's nothing fair to compare.

For a whole site, crawl with JavaScript rendering on. Then compare each requested URL with the address it ended on.

Any crawler that renders pages in a browser can record a jump that a script makes. Site Health Monitoring is one. It flags "A script sends visitors to another URL, and the server does not" once at least two pages do it. A refresh tag gets its own issue.

Replace it with a server-side redirect

Start on the server. Here's the whole fix in nginx:

location = /old-page/ {
    return 301 https://www.example.com/new-page/;
}

In Apache one line does it: Redirect 301 /old-page/ https://www.example.com/new-page/.

Then run the old URL through the redirect checker. It should show one 301 hop to the new page.

If the platform won't let you touch the server, use a meta refresh with zero seconds. Google says it "interprets instant meta refresh redirects as permanent redirects". A delayed one is read as temporary.

JavaScript comes last. When nothing else is possible, write it like this:

// Last resort. Prefer a server-side 301.
location.replace("https://www.example.com/new-page/");

Use replace, not location.href =. Replace keeps the old page out of the Back button history. Setting href leaves it in. Visitors bounce straight back to the redirect. Skip the setTimeout that tutorials add. Nothing about search needs a delay.

Once the server redirects, delete the script. Keep one mechanism per URL, or you're building redirect chains.

A redirect that only works in a browser

Run that one curl line on your own old URLs. If it prints 200 and the browser still moves, you have a JavaScript redirect.

A 301 doesn't need anyone to render anything.

Martin Stepanek

Written by

Martin Stepanek

Enterprise Technical SEO Consultant

15+ years building enterprise websites and designing the infrastructure behind them, and 5+ in technical SEO and web performance. My work is making companies findable – not just on Google, but inside ChatGPT and the other AI engines people now ask first. I write a regular newsletter and blog on technical SEO at TechSEO Vitals, and I built VitalSentinel because the gap between something breaking and someone noticing should be minutes, not days.

// newsletter

The VitalSentinel Newsletter

New features as they ship and practical technical SEO tips. One email a week at most.

Unsubscribe any time

// free to start

Know what changed on your site

Page changes, robots.txt and Core Web Vitals from real users, indexing and the Google and AI crawlers in your server logs, plus uptime and SSL, in one app.

1 domain freeNo credit cardAll 13 modules5.0on G2