Are Javascript Redirects SEO Friendly?

Posted by

So, you want to implement JavaScript reroutes, however you’re uncertain how they work?

Yes, they are more difficult to execute than basic redirects.

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

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

This is where using JavaScript redirects is available in.

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

But there are some situations where you just can not prevent utilizing a JavaScript redirect.

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

What Are JavaScript Redirects?

JavaScript reroutes, essentially, are one of a number of approaches of informing users and web crawlers that a page is available in another area.

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

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

Then, whenever someone checks out the initial URL, the browser loads the JavaScript file and carries out whatever code is inside of it. If the script includes directions to open a various URL, it does this automatically.

Doing redirects in this manner is useful in several ways.

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

A Quick Overview Of Redirect Types

There are several standard redirect types, all of which are helpful depending upon your situation.

Server-side Reroutes

Preferably, the majority of redirects will be server-side redirects.

These types of redirects stem on the server, and this is where the server chooses which place to reroute the user or 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 downsides, and they are generally suitable for more specific circumstances.

Client-side Redirects

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

Meta Refresh Redirects

The meta refresh reroute gets a bad rap and has an awful track record within the SEO community.

And for excellent factor: they are not supported by all internet browsers, and they can be confusing for the user. Rather, Google recommends using a server-side 301 redirect rather of any meta refresh redirects.

JavaScript Redirects

JavaScript redirects, however, make use of the JavaScript language to send directions 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 present problems. This is true for other kinds of platforms also, such as Spotify and other ecommerce platforms.

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

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

Js redirects are most likely not a great concept though.

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

Best Practices For SEO-Friendly JavaScript Redirects

Regardless of whether you are utilizing traditional redirects or JavaScript reroutes, there are a number of finest 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 watch 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: up to 5 hops in the chain per crawl effort).”

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

What takes place when you add another hop? It slows down the user experience. And more than 5 present substantial confusion when it pertains to Googlebot having the ability to understand your website at all.

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

However, the primary principle driving the repair work of redirect chains is: Simply ensure that you total 2 steps.

Initially, get rid of the extra hops in the redirect so that it’s under five hops.

Second, carry out a redirect that redirects the former URLs

Avoid Redirect Loops

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

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

This is why oversight of website redirects and URLs are so important: You do not want a circumstance where you execute a redirect only to learn 3 months down the line that the redirect you produced months ago was the reason for problems because it developed a redirect loop.

There are several reasons these loops are disastrous:

Regarding users, reroute loops get rid of 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 online search engine, redirect loops can be a substantial waste of your crawl budget. They also develop confusion for bots.

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

Repairing redirect loops is pretty easy: All you need to do is get rid of the redirect causing the chain’s loop and change it with a 200 OK functioning URL.

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

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

They should not be your go-to solution when you have access to other redirects because these other types of redirects are chosen.

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

More resources:

Featured Image: RoseRodionova/SMM Panel