Are Javascript Redirects SEO Friendly?

Posted by

So, you wish to carry out JavaScript redirects, however you’re unsure how they work?

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

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

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

This is where utilizing JavaScript redirects can be found in.

They are not a finest practice that you must be utilizing solely, nevertheless.

But there are some scenarios where you just can not avoid using a JavaScript redirect.

The following is a standard primer on JavaScript redirects, when to use them, how to use them, and finest practices you must use when using these kinds of redirects for SEO.

What Are JavaScript Redirects?

JavaScript redirects, essentially, are one of a number of methods of notifying users and web spiders that a page is offered in another area.

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

Many contemporary websites use these kinds of redirects to reroute to HTTPS versions of web pages.

Then, whenever somebody checks out the original URL, the browser loads the JavaScript file and carries out 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 way works in numerous ways.

For instance, you can change URLs without by hand upgrading every URL on your site. In addition, JavaScript reroutes can make it easier for search engines to find your own material.

A Quick Overview Of Redirect Types

There are a number of standard redirect types, all of which are advantageous depending upon your circumstance.

Server-side Reroutes

Preferably, most redirects will be server-side redirects.

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

For SEO factors, you will likely utilize server-side redirects most of the time. Client-side redirects have some drawbacks, and they are typically appropriate for more specific scenarios.

Client-side Redirects

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

Meta Refresh Redirects

The meta revitalize reroute gets a bum rap and has a horrible reputation within the SEO community.

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

JavaScript Redirects

JavaScript redirects, however, use the JavaScript language to send out guidelines to the browser to redirect users to another URL. There is a dominating belief that JavaScript redirects cause issues for SEO.

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

If, however, you remain in a situation where you can just use a JavaScript reroute as your only option, then you can just use JavaScript.

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

Js redirects are probably not a great concept though.

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

Finest Practices For SEO-Friendly JavaScript Redirects

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

These best practices include avoiding redirect chains and redirect loops.

What’s the distinction?

Avoid Redirect Chains

A redirect chain is a long chain of redirect hops, describing any scenario 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 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 regularly crawled. With numerous hops, the primary impact 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 attempt).”

Preferably, web designers will want to aim for no more than one hop.

What occurs when you add another hop? It decreases the user experience. And more than 5 introduce considerable confusion when it concerns Googlebot being able to comprehend your website at all.

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

However, the primary concept driving the repair work of redirect chains is: Simply make sure that you complete two actions.

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

Second, execute a redirect that redirects the previous URLs

Prevent Redirect Loops

Reroute loops, by contrast, are basically an unlimited loop of redirects. These loops happen when you redirect a URL to itself. Or, you accidentally redirect a URL within a redirect chain to a URL that takes place previously in the chain.

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

This is why oversight of site redirects and URLs are so crucial: You do not want a circumstance where you execute a redirect just to discover 3 months down the line that the redirect you created months back was the reason for concerns due to the fact that it produced a redirect loop.

There are several reasons that these loops are disastrous:

Concerning users, redirect loops remove all access to a specific resource located on a URL and will wind up triggering the browser to show a “this page has too many redirects” mistake.

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

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

Fixing redirect loops is quite easy: All you have to do is eliminate the redirect causing the chain’s loop and change it with a 200 OK working URL.

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

Be cautious about creating JavaScript redirects since they might not be the very best solution for redirects, depending on what you have access to.

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

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

More resources:

Included Image: RoseRodionova/SMM Panel