Creating an External JavaScript File
I recommend that no page that you want to be indexed by a search engine contain as little JavaScript as possible. JavaScript and other similar scripting creates excess coding for the search engine spiders to have to “read” through when looking for content they can use. A search engines robot reads the site to determine relevancy.
Having JavaScript on the page increases the amount of irrelevant source coding and hurts the pages relevancy through multiple methods including keyword density, keyword positioning, link popularity and more.
JavaScript is usually placed at the top of the page, many times within the <head></head> tags. Whatever the robot is able to read before it leaves is what it uses to determine relevancy from that individual page. Is a engine is programed to read the first 300 words or the equivalent number of characters on the site and all or most of that is “used” by JavaScript your keyword density, location and possibly the content of the entire page may get ignored.
If you can't get around having JavaScript in a site use external JavaScript files. Here is how to do it.
Suppose you have a JavaScript similar to the one below. (I have removed the middle of the script to save space.)
<script language="JavaScript">
<!-- function MM_swapImgRestore() { //v3.0 var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;}}...//-->
</script>
To create an External JavaScript file, copy your script and paste it into a text editor such as 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
Create a new folder on your server and name it what ever you wish – Like Java.
Save the text file with the extension .js you just created in the new folder on your server.
To call your JavaScript file into your web page, enter into the same place where the script originally was:
<script src="Java/java.js">
</script>
This leaves you with a nice clean page that the search engines can crawl and hopefully will index.
Recent Comments