Are Javascript Redirects SEO Friendly?

Posted by

So, you want to implement JavaScript reroutes, but you’re uncertain how they work?

Yes, they are more tough to carry out than basic redirects.

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

However … what if you do not have that level of access? What if you have an issue with producing basic redirects in such a method that would be useful to the website as a whole?

This is where utilizing JavaScript redirects can be found in.

They are not a finest practice that you need to be utilizing exclusively, however.

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

The following is a basic primer on JavaScript redirects, when to utilize them, how to utilize them, and best practices you need to use when using these kinds of redirects for SEO.

What Are JavaScript Redirects?

JavaScript redirects, basically, are among numerous approaches of notifying users and web spiders that a page is offered in another place.

They are often utilized to inform users about changes in the URL structure, but they can be utilized for just about anything.

The majority of modern-day sites use these kinds of redirects to redirect to HTTPS variations of websites.

Then, whenever someone goes to the initial URL, the internet browser loads the JavaScript file and carries out whatever code is inside of it. If the script includes directions to open a various URL, it does this immediately.

Doing redirects in this manner works in a number of ways.

For instance, you can switch URLs without by hand upgrading every single URL on your site. In addition, JavaScript reroutes can make it much easier for search engines to discover your own content.

A Quick Overview Of Redirect Types

There are numerous fundamental redirect types, all of which are helpful depending on your circumstance.

Server-side Redirects

Preferably, the majority of redirects will be server-side redirects.

These kinds of redirects come from on the server, and this is where the server chooses which location to reroute the user or 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 utilize server-side reroutes the majority of the time. Client-side redirects have some disadvantages, and they are typically appropriate for more specific situations.

Client-side Redirects

Client-side redirects are those where the browser is what decides the place of where to send out the user to. You need to not need to utilize these unless you remain in a circumstance where you do not have any other alternative to do so.

Meta Refresh Redirects

The meta refresh reroute gets a bad rap and has a horrible track record within the SEO community.

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

JavaScript Redirects

JavaScript reroutes, nevertheless, use the JavaScript language to send directions to the internet browser to redirect users to another URL. There is a dominating belief that JavaScript redirects cause issues for SEO.

Although Google does have excellent JavaScript rendering abilities nowadays, JavaScript can still present problems. This is true for other kinds of platforms likewise, such as Spotify and other ecommerce platforms.

If, however, you remain in a circumstance where you can just use a JavaScript redirect as your only choice, then you can just use JavaScript.

Likewise, Google’s Gary Illyes has stated as just recently as 2020 that JavaScript Redirects “are most likely not an excellent idea.”

Js redirects are probably not an excellent idea though.

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

Finest Practices For SEO-Friendly JavaScript Redirects

No matter whether you are using standard redirects or JavaScript reroutes, there are several finest practices you need to follow in order to not mess things up for SEO.

These best practices include preventing redirect chains and reroute loops.

What’s the difference?

Avoid Redirect Chains

A redirect chain is a long chain of redirect hops, referring to any circumstance 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 just process up to three redirects, although they have actually been understood to process more.

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

“It doesn’t matter. The only thing I ‘d watch out for is that you have less than 5 hops for URLs that are often crawled. With multiple hops, the main result is that it’s a bit slower for users. Search engines just follow the redirect chain (for Google: approximately 5 hops in the chain per crawl attempt).”

Ideally, webmasters will wish to aim for no more than one hop.

What takes place when you add another hop? It slows down the user experience. And more than 5 introduce substantial confusion when it concerns Googlebot being able to understand 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 main concept driving the repair of redirect chains is: Just ensure that you total 2 steps.

Initially, eliminate the additional hops in the redirect so that it’s under five hops.

Second, carry out a redirect that reroutes the previous URLs

Avoid Redirect Loops

Reroute loops, by contrast, are basically an infinite loop of redirects. These loops occur when you redirect a URL to itself. Or, you inadvertently 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 important: You do not want a circumstance where you implement a redirect only to learn 3 months down the line that the redirect you produced months ago was the reason for concerns because it developed a redirect loop.

There are several reasons that these loops are devastating:

Relating to users, reroute loops remove all access to a specific resource situated on a URL and will end up triggering the internet browser to display a “this page has a lot of redirects” error.

For search engines, reroute loops can be a significant waste of your crawl budget plan. They also produce confusion for bots.

This produces what’s referred to as a spider trap, and the spider can not leave the trap quickly unless it’s by hand pointed somewhere else.

Fixing redirect loops is pretty simple: All you have to do is eliminate the redirect triggering the chain’s loop and replace it with a 200 OK working URL.

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

Be cautious about developing JavaScript reroutes because they may not be the very best option for redirects, depending on what you have access to.

They should not be your go-to service when you have access to other redirects because these other types of redirects are chosen.

However, if they are the only option, you might not be shooting yourself in the foot.

More resources:

Featured Image: RoseRodionova/SMM Panel