Conductor
Try for free

Are JavaScript redirects bad for SEO?

If your only means of redirection are JavaScript redirects, then: no. Using JavaScript redirects is much better than not redirecting at all.

From an SEO point of view, a JavaScript redirect is not the most optimal way of redirecting because search engines need to render a page to find the redirect. Redirecting using a 301 redirect is always recommended (except if you're looking to temporarily redirect).

JavaScript redirects are often picked up by search engines, and they do pass authority.

If you do need to use JavaScript redirects, make sure to send consistent signals by:

  1. Including the redirect target in the XML sitemap.
  2. Update internal links to point to the redirect target.
  3. Update any canonical URLs to point to the redirect target.
Check your website for excessive redirects, and incorrect configurations right now!

Implementing JavaScript redirects

The recommended function to redirect is window.location.replace().

An example of what a JavaScript redirect to our homepage looks like:

<html> <head> <script> window.location.replace("https://www.conductor.com/"); </script> </head> </html>

This code would send a visitor to https://www.conductor.com/ upon page load.

The benefit of using the window.location.replace function is that the current URL isn't added to the visitor's navigation history, whereas the popular JavaScript redirect window.location.href would. That could cause a visitor to get stuck in back-button loops. Therefore, don't use it when redirecting visitors immediately to another URL.

<script> window.location.href='https://www.conductor.com/'; </script>
Read the full Academy article to learn everything about HTTP redirect codes for SEO explained
Share Article Details

Ready to maximize your website's potential?

Try Conductor Intelligence free for 30 days
TrustRadius logo
G2 logo
SoftwareReviews logo