SEO Optimization and JavaScript
This
article deals with whether the JavaScript Codes disrupts SEO
Optimization of your site or not.
- By the SearchEngineOptimizationPromotion.com team
You
might find a lot of articles related to using JavaScript Code
or not for better SEO Optimization. Some might advise not
to use it at all, while some advise to use it within certain
restrictions. For example, "don't use long JavaScript
codes", "use them at the bottom of your page "
etc.
First
of all make it very clear - do not fear putting the JavaScript
codes if they are really required. In no way it's going to
disrupt you in SEO Optimization. The point is WHERE to keep
the codes.
This
has been a topic of debate since a long time now as far as
SEO optimization is concerned. Do the codes really mater?
Does the placement of codes really matter?
Lets
discuss where we usually keep the JavaScript codes. Most of
the webmasters prefer inserting the JavaScript codes at the
beginning of the HTML file, between the <HEAD> and </HEAD>
section of the file.
It
goes like this:
<html>
<head>
<title>The site's title</title>
<meta name="description" content="The site's
description.">
<meta name="keywords" content="The important
keywords">
<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
function f1()
{
// The codes
}
function
f2()
{
// The codes
}
// End -->
</SCRIPT>
</head>
<body>
<p>The Body of the Page!</p>
</body>
</html>
Irrespective
of the length of the code it's always preferred there. The
question is WHY? Is it really required to be kept there as
a software rule, or the codes can be kept anywhere in the
file?
The
JavaScript codes can be kept ANYWHERE in the file. They will
work as fine. So why do the webmasters prefer keeping it there?
It's probably to maintain the clarity of the page. Moreover
if the page gets too long and the codes are scattered throughout,
it becomes difficult to find out the exact JavaScript code
that has to be debugged or that has to be changed. This is
a kind of convention too that is being followed by most of
the webmasters. So the placement of the JavaScript codes is
just a customary practice rather than a rule and it has nothing
to do with SEO optimization.
The
search engines have a mammoth task of spidering millions of
ever growing web pages. Google has already reached the 3 billion
mark. They are really busy and do not want to be loaded with
any more work.
Imagine
a web page that has just 2 lines of text or information but
120 lines of JavaScript Code. For getting those 2 lines of
information the search engines have to pass through all the
unnecessary 120 lines of code. Keeping in mind what is written
above do you think the search engines will like the page?
They are very busy and if for 2 lines of information they
have to work so hard then it's unlikely that this page will
ever get a good ranking. How much ever hard you try to optimize
it.
Many
SEO gurus have come out with an idea to tackle this problem
to optimize such a page. According to them putting the JavaScript
code at the bottom of the page will solve all the problems
since the search engines will not have to go farther down
to search the 2 lines of information.
This
is what they say:
<html>
<head>
<title>The site's title</title>
<meta name="description" content="The site's
description.">
<meta name="keywords" content="The important
keywords">
</head>
<body>
<p>The Body of the Page!</p>
<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
function f1()
{
// The codes
}
function
f2()
{
// The codes
}
// End -->
</SCRIPT>
</body>
</html>
Note that in this situation the body of the page is above
the JavaScript Code. According to the SEO gurus the search
engines will now get the content of the page before the code
and therefore the importance of the page increases. Right?
WRONG!
What
if there were 2 more lines of content right at the bottom
of the page just after the </SCRIPT> tag? The search
engines will have to come to the bottom of the page to get
those 2 lines of information. Even if you do not have any
information at the bottom of the page the search engines do
spider the whole page. They don't have any idea whatsoever
whether you have included some content at the bottom of your
page or not. The search engines look for </HTML> tag
or end of page whichever comes earlier to end their crawling.
So they crawl your whole page anyway irrespective of where
you have inserted the JavaScript code and will obviously rank
your page on the basis of the content found. This again brings
us to square one. Where should you include the JavaScript
code if at all?
Those
who know this scripting language know very well that a different
file can be created to keep all the JavaScript codes separately.
This file has an extension of .js. It is a simple file that
can be created using notepad. It has nothing except the JavaScript
code. NO HTML tags are included. You can place functions,
code and style sheets into this external Js file and refer
to the file with one line from each web page that wants to
use the functions contained in it.
This
.js file is kept in the same directory where the file in respect
of whom the codes were written resides. Whenever the required
codes are called they are taken from the .js file and executed.
This file is called only once and then taken from the cache
memory of your computer for further execution. It is retrieved
only when the cache memory is expired.
This
is how an external JavaScript file is included in the page:
<html>
<head>
<title>The site's title</title>
<meta name="description" content="The site's
description.">
<meta name="keywords" content="The important
keywords">
<SCRIPT LANGUAGE="JavaScript" SRC="externalfile.js">
</SCRIPT>
</head>
<body>
<p>The Body of the Page!</p>
</body>
</html>
This
process has a few advantages. External JavaScript files saves
bandwidth, which can be achieved by caching any JavaScripts
and Cascading Style Sheets (CSS) that are repeated often in
a web site. Secondly the length of the page reduces giving
way to faster download.
You
can always instruct a search engine to index a page or not
using a robots.txt file. Once the .js file is ready and uploaded
to the server you can always tell the search engines NOT to
index your external JavaScript file allowing them to save
their time. If you don't know how to write robots.txt file,
read article on creating
robots.txt file.
This
technique solves both the purposes - the search engines do
not have to look for the information, they get it without
wasting a second and your purpose is solved too - you give
search engines the important information fast!
However
you need not bother if your page is full of Unique and Valuable
information, or if you are providing Quality services. The
JavaScript code is a trivial matter if your site is content
rich. Secondly, the search engines actually do not spider
the JavaScript codes. As soon as they find the <SCRIPT>
tag they stop spidering. They resume their job again once
they get the </SCRIPT> tag. But they have to go through
the codes. So, by including the JavaScript code you are only
taking a little bit of their time. Yes, too much of JavaScript
code with very less content may irritate them. This is the
only reason why a page with a lot of code with comparatively
less content does not get a good Google PR (page rank). Unfortunately
it's the JavaScript code that has to take all the blame.
Truly
speaking there is an unnecessary confusion being created with
the use of JavaScript code vis-à-vis SEO optimization.
Give some useful content and great service, your JavaScript
codes will then play virtually no role in SEO optimization.
We
are highly experienced in SEO/SEM/Pay Per Click Management.
Please contact us regarding any
query you may have.
Bookmark
This Site
|