Are Javascript Redirects SEO Friendly?

Posted by

So, you wish to implement JavaScript redirects, however you’re not sure how they work?

Yes, they are more challenging to execute than standard redirects.

Ideally, you ought to utilize 301s, 302s, or 307-based redirects for execution. This is the usual best practice.

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

This is where using JavaScript redirects is available in.

They are not a best practice that you should be utilizing exclusively, nevertheless.

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

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

What Are JavaScript Redirects?

JavaScript redirects, basically, are one of numerous techniques of informing users and web spiders that a page is offered in another place.

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

A lot of modern-day websites use these types of redirects to redirect to HTTPS versions of web pages.

Then, whenever someone checks out the initial URL, the browser loads the JavaScript file and executes whatever code is inside of it. If the script consists of instructions to open a different URL, it does this automatically.

Doing redirects in this way works in several ways.

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

A Quick Overview Of Redirect Types

There are several basic redirect types, all of which are advantageous depending upon your circumstance.

Server-side Reroutes

Ideally, most 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 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 utilize server-side reroutes the majority of the time. Client-side redirects have some drawbacks, and they are normally suitable for more specific circumstances.

Client-side Redirects

Client-side redirects are those where the browser is what chooses the location of where to send the user to. You must not have to utilize these unless you’re in a scenario where you do not have any other alternative to do so.

Meta Refresh Redirects

The meta revitalize redirect gets a bum rap and has a dreadful track record within the SEO neighborhood.

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

JavaScript Redirects

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

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

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

Likewise, Google’s Gary Illyes has mentioned as recently as 2020 that JavaScript Reroutes “are probably not a good idea.”

Js redirects are most likely not a good concept though.

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

Finest Practices For SEO-Friendly JavaScript Redirects

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

These finest practices include preventing redirect chains and redirect loops.

What’s the difference?

Avoid Redirect Chains

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

Example of a redirect chain:

Reroute 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 known 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 frequently crawled. With numerous hops, the main effect 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 go for no more than one hop.

What occurs when you include another hop? It slows down the user experience. And more than 5 present significant confusion when it comes to Googlebot being able to comprehend your website at all.

Repairing redirect chains can take a lot of work, depending on their intricacy and how you set them up.

However, the main concept driving the repair of redirect chains is: Just make certain that you complete two steps.

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

Second, implement a redirect that redirects the former URLs

Avoid Redirect Loops

Reroute loops, by comparison, are essentially an infinite loop of redirects. These loops take place when you reroute a URL to itself. Or, you unintentionally reroute a URL within a redirect chain to a URL that happens 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 desire a scenario where you implement a redirect just to learn 3 months down the line that the redirect you developed months back was the reason for issues because it produced a redirect loop.

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

Relating to users, redirect loops eliminate all access to a particular resource located on a URL and will wind up triggering the browser to show a “this page has a lot of redirects” mistake.

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

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

Fixing redirect loops is quite simple: All you have to do is remove the redirect triggering the chain’s loop and replace it with a 200 okay operating URL.

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

Beware about producing JavaScript redirects due to the fact that they might not be the very best solution for redirects, depending upon what you have access to.

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

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

More resources:

Included Image: RoseRodionova/Best SMM Panel