Are Javascript Redirects SEO Friendly?

Posted by

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

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

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

However … what if you do not have that level of access? What if you have an issue with developing basic redirects in such a method that would be advantageous to the site as a whole?

This is where utilizing JavaScript reroutes comes in.

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

However there are some scenarios where you simply can not avoid utilizing a JavaScript redirect.

The following is a fundamental guide on JavaScript reroutes, when to use them, how to utilize them, and best practices you should utilize when making use of these types of redirects for SEO.

What Are JavaScript Redirects?

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

They are frequently used to inform users about changes in the URL structure, however they can be utilized for practically anything.

Many modern-day sites use these types of redirects to redirect to HTTPS variations of websites.

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

Doing redirects in this manner is useful in numerous methods.

For example, you can switch URLs without manually updating every URL on your site. In addition, JavaScript reroutes can make it simpler for online search engine to find your own content.

A Quick Summary Of Redirect Types

There are several fundamental redirect types, all of which are advantageous depending on your scenario.

Server-side Redirects

Ideally, a lot of redirects will be server-side redirects.

These types of redirects originate on the server, and this is where the server decides 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 redirects the majority of the time. Client-side redirects have some downsides, and they are typically ideal for more specific situations.

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 should not have to use these unless you’re in a circumstance where you don’t have any other alternative to do so.

Meta Refresh Redirects

The meta revitalize redirect gets a bad rap and has an awful reputation within the SEO neighborhood.

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

JavaScript Redirects

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

Although Google does have great JavaScript rendering abilities these days, JavaScript can still provide problems. This is true for other kinds of platforms also, such as Spotify and other ecommerce platforms.

If, however, you’re in a situation where you can only use a JavaScript redirect as your only option, then you can only use JavaScript.

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

Js redirects are most likely not a great idea though.

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

Best Practices For SEO-Friendly JavaScript Redirects

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

These finest practices include preventing redirect chains and redirect loops.

What’s the difference?

Prevent Redirect Chains

A redirect chain is a long chain of redirect hops, referring to 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 just process as much as three redirects, although they have been known 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 often crawled. With several hops, the primary result 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 want to go for no more than one hop.

What takes place when you include another hop? It decreases the user experience. And more than five present significant confusion when it pertains to Googlebot being able to understand your website at all.

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

However, the main principle driving the repair work of redirect chains is: Simply make certain that you total 2 actions.

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

Second, implement a redirect that reroutes the former URLs

Avoid Redirect Loops

Reroute loops, by contrast, are essentially an infinite loop of redirects. These loops occur when you reroute a URL to itself. Or, you inadvertently redirect 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 important: You do not desire a circumstance where you implement a redirect only to discover 3 months down the line that the redirect you developed months earlier was the reason for issues since it developed a redirect loop.

There are several reasons these loops are dreadful:

Relating to users, redirect loops remove all access to a particular resource located on a URL and will end up causing the browser to display a “this page has too many redirects” error.

For online search engine, redirect loops can be a considerable waste of your crawl budget plan. They also develop confusion for bots.

This produces what’s referred to as a spider trap, and the spider can not leave the trap quickly unless it’s by hand pointed somewhere else.

Fixing redirect loops is pretty easy: All you have to do is eliminate the redirect causing the chain’s loop and replace it with a 200 okay operating URL.

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

Beware about producing JavaScript reroutes because they might not be the very best service for redirects, depending on what you have access to.

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

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

More resources:

Featured Image: RoseRodionova/SMM Panel