Search engines give more importance to the text that appears near the top of the html code, rather than the text which appears downwards near the bottom. The presence of javascript in an html page pushes the actual keyword rich content downwards. Therefore, the importance of the main content, which is the key factor for web site ranking, is reduced in the eyes of the search engine robots.
Usually, web masters place the javascript codes within the <head> section of the html pages, pushing the content downwards. A sample structure of a web page which uses javascript is given below in Figure 1.

Figure 1
In the above example, the javascript code has pushed down the real content 15 lines downwards. If the javascript code was not there, the text within the <h1> tag could have been closer to the top of the page. This would have gotten it more importance from the search engine robots.
Also, the presence of javascript codes near the top of the page may affect the relevancy of the site itself. Search engines will first read the javascript, and then the body copy. They may place the first priority on the javascript code, rather than the keyword rich <h1> tag or the body copy, which hold the strong keywords for which you wish to optimize your web site in the search engines.
Whether javascript affects the relevancy of a site is a disputed topic. While Danny Sullivan of Search Engine Watch agrees to this, Jill Whalen of Rank Write Roundtable says in her article "Do JavaScripts At The Top Of The Page Impede Indexing?", published in the Rank Write Roundtable Newsletter on December 21, 2000, that most search engines ignore coding that is irrelevant to their mission. They are programmed to look for certain tags such as the Title tag and the text within the Body tag.
So, just to be on the safe side, it is advisable to place the javascript codes below the main content of the web page wherever possible (see in Figure 2). But if it is not possible to place the javascript code below the real content, you may place the javascript codes in an external file (see in Figure 3).

Figure 2
How to make your javascripts external
You can place functions, code and style sheets into an 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 technique will cause the external .js file to be placed in the cache memory, and will be retrieved from the cache every time it is called.
<script language="javascript" src="jslib.js"></script>

Figure 3
For high rankings in search engines, page ranks, and professional SEO Web Design & Website promotion services such as search engine optimization, SEO copywriting, link building, Pay Per Click, plus email newsletter publishing, contact RDI Technologies, Inc.