iEntry 10th Anniversary RSS Newsletter Advertising
Visit Twellow.com
Text: Decrease Font Size Increase Font Size | Print Print Article | Share: Delicious Digg StumbleUpon Post to Twitter Post to Facebook
Tuesday, October 31, 2006

Using External JavaScript Source Files

By now most web designers and developers know that JavaScript causes a real headache for search engine spiders.

There are however a number of scripts which, whilst not absolutely essential to the functioning of a site, are nevertheless very handy.

So where do you draw the line between keeping your page as search engine friendly as possible and including reams of JavaScript to achieve the desired effects?

You may be surprised to learn that there is an alternative which keeps search engine spiders (reasonably) happy whilst drastically cutting down on the necessary scripts within any given web page.

External JavaScript Source Files

Let's take the humble "Add Bookmark" script as an example (please note that I have replaced the < > brackets with [ ] brackets so as to be able to display the code properly within this article).

[script Language="JavaScript1.2" type="text/javascript"]
var bookmarkurl = "http://www.doodademporium.com";
var bookmarktitle = "Purple Doodads for sale";
function addbookmark()
{
if (document.all)
window.external.AddFavorite(bookmarkurl, bookmarktitle);
}
[/script]

By placing the script's function into an external folder and file (/java/bookmark.js for example) you will be able to streamline your code down to the following:

[script Language="JavaScript1.2" src="java/bookmark.js" type="text/javascript"][/script]

It's worth remembering that this is probably one of the simplest examples of JavaScript out there and that the savings in terms of code are going to be substantial with larger scripts.

This method is also worth its weight in gold, so to speak, if you are running a number of scripts on the same page.

Just remember to create a different source file for each script, so as not to confuse matters unnecessarily.

Through the use of external JavaScript files you not only save yourself having to write (or even copy/paste) the same bulky scripts again and again, you are also saving search engine spiders from becoming seriously disillusioned with your web page and going elsewhere in search of easier prey.

Always remember that any web site should make a search engine's life as easy as possible.

If you do use JavaScript in your pages, this approach will prevent unnecessary complications when having your site indexed, whilst at the same time easing your task of coding.

Tag:

Add to Del.icio.us | Digg | Reddit | Furl

Bookmark WebProNews:

An accomplished copywriter, Sasch Mayer has been writing content for web and print for well over a decade.
He is currently living in the Republic of Cyprus and working under contract to IceGiant Web Design.

News Tags: javascript, Web
About the author:
An accomplished copywriter, Sasch Mayer has been writing content for web and print for well over a decade. He is currently living in the Republic of Cyprus and working under contract to IceGiant Web Design.

Publish A Comment

The content of this field is kept private and will not be shown publicly.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.
CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
17 + 3 =
Solve this simple math problem and enter the result. E.g. for 1+3, enter 4.
SEARCH
Popular WPN Business Resources












Subscribe to WebProNews


Send me relevant info