JavaScript Redirect – Do Not Use

Among all the different kinds of redirects available, there is one that is a big Search Engine Optimization pitfall: the JavaScript redirect, which is often used by search engine spammers to serve different pages to people and search engines, a practice known as cloaking. Using a JavaScript redirect can cause search engines to mistake you for a spammer and downgrade your website accordingly.

Why Search Engines Don’t Like JavaScript Redirects

There are a few kinds of code that the Google bots can’t read very well. These include Java, JavaScript and Flash. Because these are extremely complex programming languages that the Google bot simply isn’t designed to read, search engines often skip over the code completely. In the past, that left holes in the Google bot. It allowed spammers to put redirects in JavaScript that would send people to one site, while displaying content to the search engine bots.

Naturally, Google has become much more sophisticated about detecting this kind of cloaking. Still, using JavaScript to redirect a user is considered bad form and carries with it some risk of getting penalized by the search engines. According to Google’s Webmaster Central, using a JavaScript redirect is okay as long as the intent of the code was not to deceive. Therefore, unless you have a very good reason to use a JavaScript redirect, you should probably just use a different redirect instead.

What Kind of Redirect to Use?

There are many different kinds of redirects you can use. Four common ones include the 301 redirect, the 302 redirect, the PHP redirect and the Meta redirect.

The 301 Redirect is also known as a Permanent Redirect. It tells search engines that the page has permanently moved to a new web address and that all rankings, backlinks and PageRanks should be moved accordingly.

The 302 Redirect is considered a temporary redirect. In other words, it is used by webmasters who want to send visitors to another page, but want to move it back at some later time.

Keep in mind that these redirects are written at the .htaccess level and won’t cause any speed loss at all. The server never opens the old file. Instead, when the user’s browser requests the old page, the server looks up the page, realizes it has moved and instead sends the user the new page.

The third kind of redirect is the PHP redirect. It’s slightly slower than the 301 or 302 redirect because it has to go through your server’s PHP engine. It is best used by web applications that need to use code to determine where a user needs to go on a per-case basis, as opposed to directing all visitors to a new page.

Finally, the Meta redirect is the slowest of all. It requires the visitor to completely load the page with the redirect before sending them to a new page. One of the other methods is usually better than a Meta redirect.

In summary, JavaScript redirects are frowned upon by search engines. Though they are technically not against the rules, there is no reason to take the risk. Instead, use one of the four alternative redirect types discussed above.

Share

Author: jm

Joan Mullally has been doing business online for more than 20 years and is a pioneer in the fields of online publishing, marketing, and ecommerce. She is the author of more than 200 guides and courses designed to help beginner and intermediate marketers make the most of the opportunities the Internet offers for running a successful business. A student and later teacher trainee of Frank McCourt’s, she has always appreciated the power of the word, and has used her knowledge for successful SEO and PPC campaigns, and powerful marketing copy. One computer science class at NYU was enough to spark her fascination with all things digital. In her spare time, she works with adult literacy, animal fostering and rescue, and teaching computer skills to women.