Free auditStart free
GuideSEO issue · Redirects

JavaScript 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 withChatGPTClaudePerplexityGoogleAI Mode
01Choose 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, but Google warns that rendering may fail, in which case it might never see the client-side redirect.
Method

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, 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

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 for choosing permanent versus temporary behavior.

02How it works

Check the redirect in two minutes

  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, use URL Inspection 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.

03Worth 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.

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 and HTTP status codes.

04Checklist

Verify after replacing or retaining the script

First2
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.
Next1
Update internal links, canonical tags, and sitemap entries to point to the final URL. Keep the redirect for external links and old bookmarks when the move is permanent.
Then1
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. 01Redirects and Google Searchdevelopers.google.com · checked 2026-10-24
  2. 02Understand the JavaScript SEO basicsdevelopers.google.com · checked 2026-10-24
  3. 03Fix Search-related JavaScript problemsdevelopers.google.com · checked 2026-10-24
  4. 04URL Inspection Toolsupport.google.com · checked 2026-10-24
Questions

Asked a lot.

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

01Can 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.

02Are 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.

03Should 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.

Free · 2 minutes

Tools point. Agencies advise. This one ships.

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

Free, no card60 secondsNobody will call you
  • 46 fixes shipped without a ticket Brightpipe
  • 0→7 ChatGPT citations in six weeks Paylane