# JavaScript redirects

> Understand how Google processes JavaScript redirects, when a server redirect is safer, and how to check the final URL and rendered behavior.

Canonical: https://scaplet.com/seo-issues/javascript-redirects

Guide SEO issue · Redirects

Understand how Google processes JavaScript redirects, when a server redirect is safer, and how to check the final URL and rendered behavior.

4 min

read

4

sources

Oct 24, 2026

updated

Scaplet Editorial Team

author

In one line

A JavaScript redirect changes the browser location from script after a page loads. Google can process it during rendering, but rendering can fail, so Google recommends server-side redirects when possible and meta refresh as another option. Use JavaScript redirects only when those methods are unavailable, then test the original URL, rendered result, final status, and destination.

30-second check

## Where does your site stand?

Four quick questions, then a straight answer.

1/4Have you checked your own site for this?

Summarize this page with [ChatGPT](https://chatgpt.com/?hints=search&q=Summarize%20https%3A%2F%2Fscaplet.com%2Fseo-issues%2Fjavascript-redirects%20(%22JavaScript%20redirects%22)%20in%205%20bullet%20points%2C%20then%20tell%20me%20the%20one%20thing%20I%20should%20do%20next.) [Claude](https://claude.ai/new?q=Summarize%20https%3A%2F%2Fscaplet.com%2Fseo-issues%2Fjavascript-redirects%20(%22JavaScript%20redirects%22)%20in%205%20bullet%20points%2C%20then%20tell%20me%20the%20one%20thing%20I%20should%20do%20next.) [Perplexity](https://www.perplexity.ai/search?q=Summarize%20https%3A%2F%2Fscaplet.com%2Fseo-issues%2Fjavascript-redirects%20(%22JavaScript%20redirects%22)%20in%205%20bullet%20points%2C%20then%20tell%20me%20the%20one%20thing%20I%20should%20do%20next.) [![Google](/logos/ai/google-color.svg)AI Mode](https://www.google.com/search?udm=50&q=Summarize%20https%3A%2F%2Fscaplet.com%2Fseo-issues%2Fjavascript-redirects%20(%22JavaScript%20redirects%22)%20in%205%20bullet%20points%2C%20then%20tell%20me%20the%20one%20thing%20I%20should%20do%20next.)

On this page

## 4 parts, 4 minutes.

1. [Know what Google has to do to see the redirect 01](#know-what-google-has-to-do-to-see-the-redirect)
2. [Check the redirect in two minutes 02](#check-the-redirect-in-two-minutes)
3. [Fix common client-side redirect failures 03](#fix-common-client-side-redirect-failures)
4. [Verify after replacing or retaining the script 04](#verify-after-replacing-or-retaining-the-script)

_01_Choose a redirect method based on what your server can do

## Know what Google has to do to see the redirect

With a client-side redirect, the server returns the page first; JavaScript then changes `window.location` or another location property. Google processes JavaScript in a crawl, render, and index sequence. It can see a redirect during [rendering](/glossary/rendering), but Google warns that rendering may fail, in which case it might never see the client-side redirect.

Method

### [HTTP 301](/errors/http/301) or 308

Use when

The move is permanent

Google's documented guidance

Preferred server-side method when possible; Google treats it as a signal that the target should be canonical.

Method

### [HTTP 302](/glossary/302-redirect), 303, or 307

Use when

The move is temporary

Google's documented guidance

Use when the original URL should remain eligible to appear in Search.

Method

### [Meta refresh](/glossary/meta-refresh)

Use when

Server-side redirect is unavailable

Google's documented guidance

Google interprets an instant refresh as permanent and a delayed refresh as temporary.

Method

### JavaScript `location`

Use when

You cannot use server-side or meta refresh

Google's documented guidance

Google lists it with permanent redirects, but says to use it only if you cannot do server-side or meta refresh redirects. It may never see the redirect if rendering fails.

Method

### Link with explanation

Use when

No redirect method is available

Google's documented guidance

Give people a clear link to the moved content; Google calls this a crypto redirect and says not to rely on it for Search unless there is no other choice.

For a migration or permanent URL change, a script is usually extra work: Google recommends an HTTP permanent redirect whenever technically possible. See [301 redirects](/glossary/301-redirect) for choosing permanent versus temporary behavior.

_02_How it works

## Check the redirect in two minutes

**Do not validate only the source response**A source page can return `200` and still send users elsewhere after JavaScript runs. Check both the initial response and the final rendered destination.

1. 01

### Load the original URL with JavaScript enabled

Open DevTools Network, enable Preserve log, and visit the source URL in a private window. Record the initial HTTP status, script requests, document navigations, and final address.
2. 02

### Disable JavaScript and repeat

If the redirect only happens with JavaScript enabled, it is client-side. This is a useful diagnostic comparison, not a complete reproduction of Google's renderer.
3. 03

### Inspect the rendered page

In [Search Console](/glossary/google-search-console), use [URL Inspection](/glossary/url-inspection-tool) and view the tested page. Check whether scripts loaded, whether the redirect ran, and whether the final page is the one you intended.
4. 04

### Test the destination directly

Open the final URL without relying on the redirect. Confirm it returns the correct status, loads the intended content, and has a canonical that points to the preferred URL.

_03_Worth knowing

## Fix common client-side redirect failures

### A required script fails

the location change never runs. Check blocked or failed bundles in Network, then move the redirect to the server or make the script dependency reliable.

### The destination is built from user state

a missing cookie, local storage value, or API response can send crawlers to the wrong URL. Google says its Web Rendering Service does not retain state across page loads; make the destination resolve without prior interactions.

### A locale prompt intercepts the page

keep country or language suggestions from automatically replacing a stable URL when users and crawlers should stay on that version. Provide a direct, crawlable path to each localized page.

### The source returns an error or has no content

Google may skip rendering non-200 pages. Return the right server status and redirect at the server when the content has permanently moved.

### The destination is irrelevant or broken

send users to the closest replacement, not a generic page. A redirect to an error-like destination can be treated as a [soft 404](/seo-issues/soft-404-errors).

A single-page app has a different problem when it handles a missing route in JavaScript but the server returns `200`. Google documents that this can make error pages appear in Search. For a missing route, return a real `404`, or use Google's documented SPA strategy to send the user to a server URL that returns `404` or add `noindex` to the client-side error view. See [JavaScript SEO](/glossary/javascript-seo) and [HTTP status codes](/glossary/http-status-codes).

_04_Checklist

## Verify after replacing or retaining the script

First_2_
Test the original address and destination in a browser with JavaScript on and off. The final destination should not redirect back to the source or into a long chain.

Run URL Inspection on the source after the change. The live test follows redirects, but Google says it does not indicate that it followed one or show the final URL it tested. Compare the rendered result with the destination you expect.

Next_1_
Update [internal links](/glossary/internal-links), canonical tags, and sitemap entries to point to the final URL. Keep the redirect for [external links](/glossary/backlinks) and old bookmarks when the move is permanent.

Then_1_
Check server logs or CDN rules if the result differs by host, protocol, locale, or request path. Make the redirect behavior deterministic for the same URL.

Use JavaScript redirects only when there is a concrete platform limitation. If you can configure the response at the server, a server-side redirect is clearer to browsers, crawlers, and monitoring tools.

Sources · 4

## Every fact, linked and dated.

Official docs first. The date is when we last opened each page.

- google.com

1. 01 [Redirects and Google Search](https://developers.google.com/search/docs/crawling-indexing/301-redirects) developers.google.com · checked 2026-10-24
2. 02 [Understand the JavaScript SEO basics](https://developers.google.com/search/docs/crawling-indexing/javascript/javascript-seo-basics) developers.google.com · checked 2026-10-24
3. 03 [Fix Search-related JavaScript problems](https://developers.google.com/search/docs/crawling-indexing/javascript/fix-search-javascript) developers.google.com · checked 2026-10-24
4. 04 [URL Inspection Tool](https://support.google.com/webmasters/answer/9012289?hl=en) support.google.com · checked 2026-10-24

Questions

## Asked a lot.

3 questions people ask next, answered from the sources on this page.

_01_ Can Google follow JavaScript redirects?

Google can process them during rendering, but rendering can fail. Google recommends JavaScript redirects only when server-side or meta refresh redirects are unavailable.

_02_ Are JavaScript redirects permanent or temporary?

Google's redirect table lists JavaScript `location` under permanent redirects, with the caveat that rendering can fail and Google might never see it. If the move is temporary, use an HTTP 302, 303, or 307 so the signal does not depend on rendering.

_03_ Should I use JavaScript for a moved page?

Use a server-side 301 or 308 for a permanent move when possible. Google recommends server-side permanent redirects and says JavaScript should be a fallback.

## Keep learning

[All seo issues](/seo-issues)

[Learn Temporary redirects that should be permanent Redirects](/seo-issues/temporary-redirects) [Related 301 redirect Crawling and indexing](/glossary/301-redirect) [Read next Soft 404 errors Indexability](/seo-issues/soft-404-errors) [Do Run a free site audit Free, about two minutes](/site-audit)

Nearby in SEO issues
[Infinite URL parameters](/seo-issues/infinite-url-parameters) [Intrusive interstitials](/seo-issues/intrusive-interstitial) [Keyword cannibalization](/seo-issues/keyword-cannibalization-issue) [LCP image is lazy-loaded](/seo-issues/lazy-loaded-lcp-image)

More in Redirects
[Broken redirects after a migration](/seo-issues/broken-redirects-after-migration) [JavaScript redirects](/seo-issues/javascript-redirects) [Redirect chains](/seo-issues/redirect-chains) [Redirect loops](/seo-issues/redirect-loops) [Redirects to a 404](/seo-issues/redirect-to-404) [Temporary redirects that should be permanent](/seo-issues/temporary-redirects)

Terms on this page
[Rendering](/glossary/rendering) [302 redirect](/glossary/302-redirect) [Meta refresh](/glossary/meta-refresh) [301 redirect](/glossary/301-redirect) [Google Search Console](/glossary/google-search-console) [URL Inspection tool](/glossary/url-inspection-tool) [JavaScript SEO](/glossary/javascript-seo) [HTTP status codes](/glossary/http-status-codes)

Free · 2 minutes

## Tools point. Agencies advise. _This one ships._

Run the free audit, then approve the fixes. Every change can be undone.

[Audit my site free](/site-audit)

Free, no card 60 seconds Nobody will call you

- **46** fixes shipped without a ticket Brightpipe
- **0→7** ChatGPT citations in six weeks Paylane
