Are Javascript Redirects SEO Friendly?

Posted by

So, you want to implement JavaScript redirects, but you’re unsure how they work?

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

Ideally, you must utilize 301s, 302s, or 307-based redirects for application. This is the normal finest practice.

However … what if you don’t have that level of access? What if you have an issue with producing 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 exclusively, nevertheless.

However there are some scenarios where you just can not prevent utilizing a JavaScript redirect.

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

What Are JavaScript Redirects?

JavaScript redirects, essentially, are among several methods of informing users and web spiders that a page is offered in another area.

They are typically utilized to notify users about changes in the URL structure, but they can be utilized for almost anything.

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

Then, whenever somebody visits the original URL, the browser loads the JavaScript file and carries out whatever code is within it. If the script consists of instructions to open a various URL, it does this automatically.

Doing redirects in this manner is useful in a number of methods.

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

A Quick Overview Of Redirect Types

There are numerous standard redirect types, all of which are beneficial depending upon your circumstance.

Server-side Reroutes

Preferably, most redirects will be server-side redirects.

These types of redirects stem on the server, and this is where the server chooses which location to redirect 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 use server-side reroutes the majority of the time. Client-side redirects have some drawbacks, and they are normally appropriate for more particular scenarios.

Client-side Redirects

Client-side redirects are those where the internet browser is what decides the area of where to send out the user to. You need to not have to utilize these unless you’re in a scenario where you don’t have any other alternative to do so.

Meta Refresh Redirects

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

And for great reason: they are not supported by all browsers, and they can be confusing for the user. Rather, Google suggests using a server-side 301 redirect rather of any meta refresh reroutes.

JavaScript Redirects

JavaScript redirects, however, utilize the JavaScript language to send instructions to the 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 capabilities these days, JavaScript can still provide problems. This holds true for other types of platforms likewise, such as Spotify and other ecommerce platforms.

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

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

Js redirects are probably not a good idea 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 several best practices you must follow in order to not mess things up for SEO.

These best practices include avoiding 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:

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

Why are these bad? Google can only process approximately 3 redirects, although they have 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 keep an eye out for is that you have less than 5 hops for URLs that are frequently crawled. With numerous hops, the main result 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).”

Ideally, webmasters will wish to aim for no greater than one hop.

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

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

But, the primary principle driving the repair of redirect chains is: Just make sure that you complete two steps.

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

Second, execute a redirect that redirects the former URLs

Prevent Redirect Loops

Reroute loops, by contrast, are essentially an infinite loop of redirects. These loops occur when you redirect a URL to itself. Or, you unintentionally reroute a URL within a redirect chain to a URL that takes place 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 do not desire a scenario where you execute a redirect just to learn 3 months down the line that the redirect you produced months earlier was the cause of concerns due to the fact that it developed a redirect loop.

There are several reasons these loops are dreadful:

Regarding users, reroute loops get rid of all access to a particular resource situated on a URL and will wind up causing the browser to show a “this page has a lot of redirects” mistake.

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

This produces what’s described as a crawler trap, and the crawler can not leave the trap easily unless it’s manually pointed elsewhere.

Repairing redirect loops is pretty simple: All you have to do is eliminate the redirect triggering the chain’s loop and change it with a 200 okay operating URL.

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

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

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

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

More resources:

Featured Image: RoseRodionova/Best SMM Panel