Are Javascript Redirects SEO Friendly?

Posted by

So, you want to execute JavaScript reroutes, but you’re unsure how they work?

Yes, they are more tough to implement than basic redirects.

Preferably, you need to utilize 301s, 302s, or 307-based redirects for implementation. This is the typical finest practice.

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

This is where using JavaScript reroutes is available in.

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

However there are some situations where you just can not avoid using a JavaScript redirect.

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

What Are JavaScript Redirects?

JavaScript reroutes, essentially, are one of several approaches of notifying users and web spiders that a page is offered in another location.

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

Many modern-day websites use these kinds of redirects to redirect to HTTPS versions of websites.

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

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

For instance, you can change URLs without manually upgrading every URL on your website. In addition, JavaScript reroutes can make it much easier for search engines to find your own content.

A Quick Introduction Of Redirect Types

There are numerous basic redirect types, all of which are useful depending on your circumstance.

Server-side Reroutes

Ideally, most redirects will be server-side redirects.

These kinds of redirects stem on the server, and this is where the server chooses 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 utilize server-side redirects most of the time. Client-side redirects have some drawbacks, and they are typically suitable for more specific scenarios.

Client-side Redirects

Client-side redirects are those where the internet browser is what decides the place of where to send the user to. You ought to not have to utilize these unless you’re in a situation where you do not have any other alternative to do so.

Meta Refresh Redirects

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

And for excellent 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 reroutes.

JavaScript Redirects

JavaScript redirects, nevertheless, utilize the JavaScript language to send out directions 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 great JavaScript rendering abilities these days, JavaScript can still present concerns. This holds true for other kinds of platforms also, such as Spotify and other ecommerce platforms.

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

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

Js redirects are most likely not an excellent concept though.

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

Best Practices For SEO-Friendly JavaScript Redirects

No matter whether you are utilizing conventional 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 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 actually been known to process more.

Google’s John Mueller recommends 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 regularly crawled. With multiple hops, the primary 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 wish to aim for no more than one hop.

What takes place when you add another hop? It decreases the user experience. And more than 5 present substantial 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 complexity and how you set them up.

However, the primary principle driving the repair work of redirect chains is: Just ensure that you complete two steps.

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

Second, carry out a redirect that redirects the previous URLs

Prevent Redirect Loops

Reroute loops, by contrast, are basically a boundless loop of redirects. These loops occur when you reroute a URL to itself. Or, you unintentionally redirect a URL within a redirect chain to a URL that occurs 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 essential: You don’t desire a scenario where you execute a redirect just to learn 3 months down the line that the redirect you developed months earlier was the reason for problems due to the fact that it created a redirect loop.

There are numerous reasons these loops are disastrous:

Concerning users, redirect loops eliminate all access to a particular resource situated on a URL and will end up causing the web browser to show a “this page has too many redirects” mistake.

For search engines, redirect loops can be a considerable waste of your crawl spending plan. They also create confusion for bots.

This produces 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 easy: All you need to do is eliminate the redirect triggering the chain’s loop and replace it with a 200 okay functioning URL.

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

Be cautious about creating JavaScript redirects since they may not be the very best service 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 preferred.

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

More resources:

Featured Image: RoseRodionova/Best SMM Panel