Are Javascript Redirects SEO Friendly?

Posted by

So, you want to execute JavaScript reroutes, however you’re unsure how they work?

Yes, they are more difficult to implement than basic redirects.

Ideally, you need to use 301s, 302s, or 307-based redirects for application. This is the typical best practice.

But … what if you don’t have that level of access? What if you have an issue with producing standard redirects in such a method that would be helpful to the website as a whole?

This is where using JavaScript redirects comes in.

They are not a finest practice that you should be using specifically, nevertheless.

But there are some circumstances where you simply can not avoid utilizing a JavaScript redirect.

The following is a standard guide on JavaScript reroutes, when to use them, how to use them, and best practices you must utilize when making use of these kinds of redirects for SEO.

What Are JavaScript Redirects?

JavaScript reroutes, essentially, are one of several approaches of informing users and web spiders that a page is offered in another location.

They are often utilized to notify users about modifications in the URL structure, however they can be used for practically anything.

Most modern sites utilize these kinds of redirects to redirect to HTTPS versions of web pages.

Then, whenever somebody goes to the original URL, the browser loads the JavaScript file and performs whatever code is inside of it. If the script consists of directions to open a various URL, it does this automatically.

Doing redirects in this manner is useful in several ways.

For instance, you can switch URLs without by hand upgrading every single URL on your website. In addition, JavaScript redirects can make it simpler for search engines to find your own content.

A Quick Overview Of Redirect Types

There are a number of standard redirect types, all of which are beneficial depending upon your situation.

Server-side Redirects

Ideally, most redirects will be server-side redirects.

These types of redirects stem on the server, and this is where the server chooses which place to reroute the user or online search engine to when a page loads. And the server does this by returning a 3xx HTTP status code.

For SEO reasons, you will likely use server-side reroutes the majority of the time. Client-side redirects have some downsides, and they are normally appropriate for more specific circumstances.

Client-side Redirects

Client-side redirects are those where the web browser is what chooses the place of where to send out the user to. You need to not have to use these unless you’re in a circumstance where you do not have any other choice to do so.

Meta Refresh Redirects

The meta refresh reroute gets a bum rap and has a terrible credibility within the SEO community.

And for great reason: they are not supported by all web browsers, and they can be puzzling for the user. Rather, Google suggests using a server-side 301 redirect rather of any meta refresh redirects.

JavaScript Redirects

JavaScript redirects, nevertheless, use the JavaScript language to send out guidelines to the web browser to reroute users to another URL. There is a dominating belief that JavaScript reroutes cause problems for SEO.

Although Google does have great JavaScript rendering abilities these days, JavaScript can still provide issues. This holds true for other types of platforms also, such as Spotify and other ecommerce platforms.

If, however, you’re in a circumstance where you can only utilize a JavaScript reroute as your only choice, then you can only utilize JavaScript.

Also, Google’s Gary Illyes has actually stated as just recently as 2020 that JavaScript Reroutes “are probably not an excellent idea.”

Js redirects are probably not a good concept though.

— Gary 鯨理 / 경리 Illyes (@methode) July 8, 2020

Best Practices For SEO-Friendly JavaScript Redirects

Despite whether you are utilizing traditional redirects or JavaScript redirects, there are several finest practices you must follow in order to not mess things up for SEO.

These finest practices include preventing redirect chains and redirect loops.

What’s the difference?

Prevent Redirect Chains

A redirect chain is a long chain of redirect hops, referring to any situation where you have more than 1 redirect in a chain.

Example of a redirect chain:

Redirect 1 > redirect 2 > redirect 3 > redirect 4 > redirect 5

Why are these bad? Google can only process up to three redirects, although they have been understood to process more.

Google’s John Mueller recommends less than 5 hops per redirect.

“It does not matter. The only thing I ‘d look out for is that you have less than 5 hops for URLs that are regularly crawled. With numerous hops, the primary effect is that it’s a bit slower for users. Search engines simply follow the redirect chain (for Google: up to 5 hops in the chain per crawl attempt).”

Ideally, webmasters will wish to go for no greater than one hop.

What happens when you add another hop? It decreases the user experience. And more than five introduce considerable confusion when it comes to Googlebot having the ability to comprehend your site at all.

Repairing redirect chains can take a great deal of work, depending upon their complexity and how you set them up.

However, the primary principle driving the repair of redirect chains is: Simply ensure that you complete two actions.

First, eliminate the extra hops in the redirect so that it’s under five hops.

Second, execute a redirect that redirects the previous URLs

Prevent Redirect Loops

Reroute loops, by comparison, are essentially an unlimited loop of redirects. These loops take place when you reroute a URL to itself. Or, you accidentally reroute a URL within a redirect chain to a URL that occurs previously in the chain.

Example of a redirect loop: Reroute 1 > redirect 2 > redirect 3 > redirect 2

This is why oversight of site redirects and URLs are so crucial: You don’t want a scenario where you implement a redirect only to discover 3 months down the line that the redirect you created months earlier was the cause of problems due to the fact that it developed a redirect loop.

There are a number of reasons why these loops are dreadful:

Relating to users, redirect loops get rid of all access to a specific resource situated on a URL and will end up causing the internet browser to display a “this page has too many redirects” mistake.

For online search engine, redirect loops can be a significant waste of your crawl budget. They likewise create confusion for bots.

This develops what’s described as a spider trap, and the crawler can not leave the trap easily unless it’s manually pointed somewhere else.

Repairing redirect loops is pretty easy: All you have to do is get rid of the redirect causing the chain’s loop and replace it with a 200 OK functioning URL.

Want To Use JavaScript Redirects For SEO? Not So Quick …

Beware about developing JavaScript reroutes since they might not be the very best option for redirects, depending upon what you have access to.

They must not be your go-to solution when you have access to other redirects because these other kinds of redirects are preferred.

But, if they are the only alternative, you may not be shooting yourself in the foot.

More resources:

Featured Image: RoseRodionova/Best SMM Panel