Are Javascript Redirects SEO Friendly?

Posted by

So, you want to carry out JavaScript redirects, but you’re not sure how they work?

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

Ideally, you must use 301s, 302s, or 307-based redirects for execution. This is the typical finest 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 way that would be advantageous to the website as a whole?

This is where using JavaScript reroutes can be found in.

They are not a best practice that you must be utilizing specifically, nevertheless.

However there are some circumstances where you simply can not avoid using a JavaScript redirect.

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

What Are JavaScript Redirects?

JavaScript reroutes, essentially, are one of numerous techniques of notifying users and web crawlers that a page is readily available in another place.

They are typically used to notify users about changes in the URL structure, however they can be used for just about anything.

Many modern websites use these types of redirects to redirect to HTTPS versions of web pages.

Then, whenever someone checks out the original URL, the browser loads the JavaScript file and executes whatever code is within it. If the script includes instructions to open a various URL, it does this immediately.

Doing redirects in this manner is useful in numerous ways.

For example, you can change URLs without manually upgrading each and every single URL on your website. In addition, JavaScript reroutes can make it easier for online search engine to discover your own content.

A Quick Overview Of Redirect Types

There are a number of standard redirect types, all of which are useful depending on your scenario.

Server-side Reroutes

Preferably, the majority 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 factors, you will likely use server-side redirects the majority of the time. Client-side redirects have some downsides, and they are typically ideal for more specific circumstances.

Client-side Redirects

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

Meta Refresh Redirects

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

And for good reason: they are not supported by all web browsers, and they can be confusing for the user. Rather, Google advises utilizing a server-side 301 redirect instead of any meta refresh redirects.

JavaScript Redirects

JavaScript redirects, however, use the JavaScript language to send instructions to the internet browser to reroute users to another URL. There is a dominating belief that JavaScript reroutes cause problems for SEO.

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

If, nevertheless, you’re in a circumstance where you can just use a JavaScript reroute as your only option, then you can just use JavaScript.

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

Js redirects are most likely not a great concept though.

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

Best Practices For SEO-Friendly JavaScript Redirects

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

These finest practices consist of avoiding redirect chains and redirect loops.

What’s the distinction?

Prevent 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:

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

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

Google’s John Mueller recommends 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 frequently crawled. With several hops, the primary effect is that it’s a bit slower for users. Online search engine just follow the redirect chain (for Google: approximately 5 hops in the chain per crawl effort).”

Preferably, web designers will wish to go for no greater than one hop.

What occurs when you include another hop? It decreases the user experience. And more than five introduce 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 complexity and how you set them up.

But, the main concept driving the repair of redirect chains is: Just make certain that you total 2 steps.

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

Second, carry out a redirect that reroutes the previous URLs

Avoid Redirect Loops

Reroute loops, by comparison, are essentially an infinite 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 happens previously in the chain.

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

This is why oversight of website redirects and URLs are so important: You don’t desire a scenario where you carry out a redirect just to learn 3 months down the line that the redirect you developed months back was the cause of concerns since it created a redirect loop.

There are several reasons that these loops are dreadful:

Relating to users, reroute loops eliminate all access to a specific resource situated on a URL and will end up causing the internet browser to show a “this page has too many redirects” mistake.

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

This creates what’s referred to as a crawler trap, and the crawler can not leave the trap quickly unless it’s manually pointed elsewhere.

Repairing redirect loops is quite easy: All you have to do is get rid of the redirect triggering the chain’s loop and change it with a 200 OK operating URL.

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

Be cautious about creating JavaScript redirects since they may not be the 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 due to the fact that these other kinds of redirects are chosen.

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

More resources:

Featured Image: RoseRodionova/Best SMM Panel