Every Search Engines have special criteria to check the
content of the web page. The Search Engine wants to return the results most relevant
to a user's search. But there are some criteria which remain same. One of these is where the keywords are located on the page. Another measure of relevance is "keyword density". This is
roughly the ratio of keywords on a page to the total number
of words on a page. Having a higher ratio of keywords to
total words will make a page more relevant for a search on
those keywords. When a Search Engine sends its robot out to look at your
page, you want to make sure that it finds important
information near the top of the web page, and that the page
has a high keyword density. One of the complications,
extensive JavaScript code, can be easily remedied. JavaScript problem Typically the largest amount of JavaScript code in a web page
is found in the HEAD section. Unfortunately, having a large
amount of JavaScript code in a page can be detrimental to a
page's ranking in the Search Engines. Since Search Engines tend to pay more attention to text at
the beginning of a web page than they do to text further
from the beginning. Keyword density is also important. Here again, if you have
several hundred words of JavaScript code in a page, the
keyword density—the ratio of your keywords to all the words
in the whole page, both text and code—is going to be much
lower. That means that some Search Engines will decide that
your page is less relevant. JavaScript solution So to maintain JavaScript functionality, and make your page
as Search Engine-friendly as possible? You put the
JavaScript code into a separate file, and link it back to
the web page. The original page, "page1.html", may look something like
this.
<html>
<head>
<title>My Title</title>
<script>
function Welcome(){
alert("Welcome!");
return;
}
</script>
</head>
<body onLoad="Welcome()">
...body of page...
</body>
</html>
page1.html with JavaScript code We replace the JavaScript code with an instruction for the
browser to go and grab the code from a separate file. The
new page will look like this.
<html>
<head>
<title>My Title</title>
<script src="codepage.js"></script>
</head>
<body onLoad="Welcome()">
...body of page...
</body>
</html>
mypage.html with JavaScript code offloaded Note the addition of the "src" attribute to the SCRIPT tag.
The value assigned to that attribute is the name of the
external file that contains the JavaScript code. Typically,
these external files will be given the filename extension ".js"
to indicate that they contain JavaScript code. Note also
that there are both <script> and </script> tags here, even
though there is nothing between those tags. A new page is then created that holds the code that was
formerly held in the SCRIPT tags. We will call it "codepage.js",
and it looks like this.
function Welcome(){
alert("Welcome!");
return;
}
As such your web page is more friendly to the Search Engines. This means
that the next time your page is spidered by the Search
Engine robots, the important content on your page will be
closer to the top of the page, and you will have a better
keyword density. This will result in your page appearing
higher in the Search Engine listings resulting in greater
traffic to your website. |