Are Javascript Redirects SEO Friendly?

Posted by

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

Yes, they are more challenging to carry out than standard redirects.

Preferably, you should utilize 301s, 302s, or 307-based redirects for implementation. This is the usual best practice.

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

This is where using JavaScript redirects can be found in.

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

But there are some circumstances where you simply can not prevent using a JavaScript redirect.

The following is a basic primer on JavaScript redirects, when to utilize them, how to utilize them, and finest practices you need to utilize when utilizing these types of redirects for SEO.

What Are JavaScript Redirects?

JavaScript redirects, essentially, are among numerous methods of informing users and web crawlers that a page is offered in another location.

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

Many modern-day websites utilize these types of redirects to reroute to HTTPS variations of websites.

Then, whenever somebody visits the initial URL, the browser loads the JavaScript file and performs whatever code is inside of it. If the script includes directions to open a different URL, it does this automatically.

Doing redirects in this way is useful in several methods.

For example, you can switch URLs without manually upgrading each and every single URL on your website. In addition, JavaScript reroutes can make it simpler for search engines to find your own content.

A Quick Summary Of Redirect Types

There are several standard redirect types, all of which are helpful depending on your circumstance.

Server-side Redirects

Ideally, a lot of redirects will be server-side redirects.

These types of redirects come from on the server, and this is where the server decides 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 redirects the majority of the time. Client-side redirects have some disadvantages, and they are generally appropriate for more specific situations.

Client-side Redirects

Client-side redirects are those where the browser is what decides the area of where to send out the user to. You need to not have to use these unless you remain in a situation where you don’t have any other alternative to do so.

Meta Refresh Redirects

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

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

JavaScript Redirects

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

Although Google does have good JavaScript rendering abilities nowadays, JavaScript can still provide issues. This is true for other types of platforms also, such as Spotify and other ecommerce platforms.

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

Likewise, Google’s Gary Illyes has stated as just recently as 2020 that JavaScript Redirects “are probably not a great idea.”

Js redirects are most likely not an excellent concept though.

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

Finest Practices For SEO-Friendly JavaScript Redirects

No matter whether you are utilizing traditional redirects or JavaScript redirects, there are several best practices you should follow in order to not mess things up for SEO.

These best practices include preventing redirect chains and reroute loops.

What’s the distinction?

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 3 redirects, although they have 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 look 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 simply follow the redirect chain (for Google: as much as 5 hops in the chain per crawl effort).”

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

What occurs when you include another hop? It decreases the user experience. And more than 5 introduce considerable confusion when it concerns Googlebot having the ability to understand your website at all.

Fixing redirect chains can take a great deal of work, depending on their intricacy and how you set them up.

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

Initially, remove the additional hops in the redirect so that it’s under 5 hops.

Second, implement a redirect that redirects the previous URLs

Prevent Redirect Loops

Reroute loops, by comparison, are basically an unlimited loop of redirects. These loops occur when you reroute a URL to itself. Or, you unintentionally reroute a URL within a redirect chain to a URL that takes place 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 don’t want a situation where you carry out a redirect just 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 numerous reasons why these loops are devastating:

Relating to users, reroute loops remove all access to a particular resource located on a URL and will wind up triggering the browser to display a “this page has too many redirects” error.

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

This creates what’s described as a spider trap, and the crawler can not get out of the trap easily unless it’s manually pointed somewhere else.

Repairing redirect loops is pretty simple: All you need to do is get rid of the redirect causing the chain’s loop and replace it with a 200 okay working URL.

Wish To Utilize JavaScript Redirects For SEO? Not So Fast …

Beware about developing JavaScript redirects due to the fact that they might not be the best option for redirects, depending on what you have access to.

They need to not be your go-to solution when you have access to other redirects due to the fact that 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:

Included Image: RoseRodionova/Best SMM Panel