Are Javascript Redirects SEO Friendly?

Posted by

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

Yes, they are more challenging to implement than standard redirects.

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

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

This is where using JavaScript reroutes is available in.

They are not a best practice that you must be using solely, however.

But there are some situations where you simply can not avoid utilizing a JavaScript redirect.

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

What Are JavaScript Redirects?

JavaScript redirects, essentially, are among several methods of notifying users and web spiders that a page is available in another location.

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

Most contemporary sites use these kinds of redirects to redirect to HTTPS variations of web pages.

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

Doing redirects in this way is useful in numerous ways.

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

A Quick Introduction Of Redirect Types

There are numerous standard redirect types, all of which are advantageous depending on your scenario.

Server-side Redirects

Preferably, a lot 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 factors, you will likely utilize server-side redirects the majority of the time. Client-side redirects have some drawbacks, and they are generally ideal for more particular scenarios.

Client-side Redirects

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

Meta Refresh Redirects

The meta revitalize reroute gets a bum rap and has a dreadful reputation within the SEO neighborhood.

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

JavaScript Redirects

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

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

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

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

Js redirects are probably not a great concept though.

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

Finest Practices For SEO-Friendly JavaScript Redirects

Despite whether you are using traditional redirects or JavaScript redirects, there are a number of finest practices you must follow in order to not mess things up for SEO.

These finest practices consist of preventing redirect chains and reroute 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:

Reroute 1 > redirect 2 > redirect 3 > redirect 4 > redirect 5

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

Google’s John Mueller suggests less than 5 hops per redirect.

“It does not matter. The only thing I ‘d look out for is that you have less than 5 hops for URLs that are often crawled. With multiple hops, the main result is that it’s a bit slower for users. Online search engine simply follow the redirect chain (for Google: as much as 5 hops in the chain per crawl attempt).”

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

What happens when you add another hop? It decreases the user experience. And more than 5 introduce significant confusion when it concerns Googlebot having the ability to comprehend your website at all.

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

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

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

Second, implement a redirect that redirects the previous URLs

Avoid Redirect Loops

Reroute loops, by contrast, are essentially a boundless loop of redirects. These loops happen when you reroute a URL to itself. Or, you mistakenly reroute a URL within a redirect chain to a URL that occurs earlier 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 essential: You do not 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 concerns due to the fact that it produced a redirect loop.

There are numerous reasons that these loops are dreadful:

Concerning users, reroute loops eliminate all access to a specific resource situated on a URL and will end up triggering the browser to show a “this page has a lot of redirects” error.

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

This produces what’s referred to as a crawler trap, and the crawler can not get out of the trap easily unless it’s by hand pointed elsewhere.

Repairing redirect loops is pretty simple: All you need to do is remove the redirect causing the chain’s loop and change it with a 200 okay working URL.

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

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

They should not be your go-to service when you have access to other redirects since these other kinds of redirects are preferred.

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

More resources:

Featured Image: RoseRodionova/SMM Panel