Friday, June 13, 2008

How to Make Java Script Search Engine Friendly

How to Make Java Script Search Engine Friendly
Think of the search engines like a child with a short
attention span. If they have to crawl through tons of
messy code before they get to the body content on your
page, there is a chance they will "lose interest" and not
continue spidering the page.

Since you want the engines to be able to spider all of your
content pages, you should minimize the amount of extraneous
code that is on your page. You worked hard to create your
content and get your site optimized, so the last thing you
want to do is take a chance that the engines won't want to
spider your pages.

One way to clean up the code is to take java script that is
on-page and put it in an external .js file.

Java script on your page usually takes up anywhere from 3 -
8+ lines of code. That is all just creates extra code that
the spiders have to crawl through before they get to your
body text. You are better off calling your java script in
from a .js file. This takes what used to be many lines of
code on your page and reduces it to one line where you just
call the script in.

To create an External JavaScript file:

Copy your script and paste it into Notepad.

Remove the beginning and end script commands. They are:

< script language="JavaScript"> and < /script>

Next, do a SAVE AS command and save the file as "text only"
with an extension of .js

Example: java.js

Upload the file to a folder on your server that you name
Java. (Or whatever name you wish.)

To call your Java file into your web page, enter into the
same place where the script originally was:

< script src="Java/java.js"> < /script >

Lastly, if you wish to hide the text from JavaScript
impaired browsers to avoid error codes, surround the
JavaScript with <!-- and --> in your java.js file.

This will make for cleaner code, and the functionality will
still be the same.

You could also move your script to the bottom of the page -
but remember if the page doesn't fully load then your
script may not load, so it could impact the functionality
of your page.

Whatever solution you choose to implement - make sure you
test it to ensure it works. Once the engines pick up your
pages and the traffic to your site increases, you want to
be sure the site is fully functional and in tip top shape.


----------------------------------------------------
Jennifer Horowitz is the Director of Marketing for
EcomBuffet.com. Over the past 10 years Jennifer's expertise
in marketing and Search Engine Optimization (SEO) has
helped clients increase revenue. Jennifer has written a
downloadable book on SEO and has been published in many SEO
and marketing publications. Jennifer is the editor of the
popular Spotlight on Success: SEO and Marketing newsletter.
Follow Jennifer and stay current on SEO, marketing, social
media and more.

http://twitter.com/EcomBuffet

No comments: