Are Javascript Redirects SEO Friendly?

Posted by

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

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

Ideally, you should use 301s, 302s, or 307-based redirects for implementation. This is the typical best practice.

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

This is where using JavaScript reroutes can be found in.

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

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

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

What Are JavaScript Redirects?

JavaScript redirects, essentially, are one of a number of techniques of informing users and web crawlers that a page is available in another location.

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

Most modern-day websites utilize these types of redirects to reroute to HTTPS variations of web pages.

Then, whenever somebody visits the initial URL, the internet browser loads the JavaScript file and executes whatever code is inside of it. If the script consists of guidelines to open a different URL, it does this immediately.

Doing redirects in this way is useful in several ways.

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

A Quick Overview Of Redirect Types

There are numerous standard redirect types, all of which are beneficial depending on your situation.

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 decides which area to redirect 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 reroutes the majority of the time. Client-side redirects have some downsides, and they are usually ideal for more specific scenarios.

Client-side Redirects

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

Meta Refresh Redirects

The meta refresh redirect gets a bad rap and has a terrible credibility within the SEO community.

And for great factor: they are not supported by all web browsers, and they can be puzzling for the user. Rather, Google advises using a server-side 301 redirect instead of any meta refresh redirects.

JavaScript Redirects

JavaScript redirects, however, utilize the JavaScript language to send directions to the web 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 nowadays, JavaScript can still present issues. This is true for other kinds 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 use JavaScript.

Likewise, Google’s Gary Illyes has mentioned as just recently as 2020 that JavaScript Reroutes “are most likely not an excellent idea.”

Js redirects are probably not a good idea though.

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

Finest Practices For SEO-Friendly JavaScript Redirects

Regardless of whether you are utilizing conventional redirects or JavaScript reroutes, there are a number of best practices you should follow in order to not mess things up for SEO.

These finest practices include preventing redirect chains and reroute 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 recommends 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 regularly crawled. With numerous hops, the main result is that it’s a bit slower for users. Search engines just follow the redirect chain (for Google: up to 5 hops in the chain per crawl effort).”

Ideally, web designers will wish to aim for no more than one hop.

What happens when you include another hop? It slows down the user experience. And more than 5 present significant confusion when it comes to Googlebot being able to understand your website at all.

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

However, the main concept driving the repair of redirect chains is: Simply make sure that you complete 2 actions.

First, eliminate the extra hops in the redirect so that it’s under five hops.

Second, carry out a redirect that redirects the previous URLs

Avoid Redirect Loops

Reroute loops, by comparison, 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 occurs previously in the chain.

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

This is why oversight of site redirects and URLs are so crucial: You don’t want a situation where you implement a redirect only to discover 3 months down the line that the redirect you produced months earlier was the reason for issues due to the fact that it produced a redirect loop.

There are several reasons why these loops are devastating:

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

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

This develops 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 simple: All you have to do is get rid of the redirect causing the chain’s loop and change it with a 200 OK working URL.

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

Beware about developing JavaScript redirects due to the fact that they might not be the very best option for redirects, depending on what you have access to.

They must not be your go-to solution when you have access to other redirects due to the fact that these other types of redirects are chosen.

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

More resources:

Featured Image: RoseRodionova/Best SMM Panel