SEO Kryponite Showdown Part 2: JavaScript

JavaScript Kryptonite

SEO KryptoniteWhat is JavaScript? Used to create dynamic, interactive user experiences on websites, JavaScript is a programming language that runs on the site visitors computer, meaning it’s client side computing.  Support for JavaScript is built right into modern web browsers, as long as the visitor has JavaScript enabled.

Are JavScript and Java the same? No. They are not related, other than both being computer programming languages and their authors apparently loved coffee. “Java is to JavaScript what Car is to Carpet” is a common explanation of their relation- which is ‘not much’.

JavaScript is not JavaWhat’s the problem with JavaScript? As a internet programming language- it’s great. It creates interactive elements for web pages, such as: validating input values in web forms, opening windows with controls over size and position or images changing when a mouse hovers over them. JavaScript becomes problematic when applied to links. Links created in HTML are straightforward and easy for search engines to read, index and pass juice to and from. However, their is a lot of uncertainty in the SEO world about the link juice that gets passed from JavaScript links. We know that Google crawls and recognizes these for link discovery, but the amount of  link juice is another story. There are many different ways to create links with JavaScript and which is best for SEO is unknown- and should thus be avoided.

Code Examples

HTML Link

<a href=”clean-and-easy-url.html“>anchor text to click</a>

JavaScript Link

In the head of the document:

<head>
<script language=”JavaScript”>
function MyFunctionName()
{
// javascript code
}
</script>
</head>

The link in the body of the page is them created:

<a href=”javascript:MyFunctionName();“>anchor text to click</a>

Another option is to put the JavaScript in the link itself:

<a href=”/convoluted-url/?siteUrl=’ + escape($(“#id_siteUrl”).val() )+ ‘”>

 

What is an SEO to Do?

Whenever possible, use HTML for all links. There are just too many unknowns about the juice that is getting passed. If a JavaScript link is absolutetly mandetory, you may want to consider adding additional HTML links on the page to aid with the SEO. Whenever possible, implement standard <a href=””></a> links.

Helpful resources

Crawling the internet– Basics of search engine viewable content and links

– Can Google index and pass juice from JavaScript links?

JavaScript and Links Q& A

JavaScript Links and SEO Discussion

Feedback: What are some good and bad uses you’ve seen of JS? What resources have you found for using JS effectively for SEO?