Javascripts on Webpages
As web pages get increasingly more advanced so does the amount of code needed. The result may be a beautiful looking page that performs many things well...except ranking highly in the search engines. Search engine spiders are fussy eaters and don't really like anything with their HTML, especially not a side order of JavaScript.
First check the source code of your web page, especially the <head> section as this is where most JavaScript is placed. For example, if your page includes rollover buttons it's probably heavy with JavaScript. All this code gets in the way of the spiders and doesn't help in achieving good rankings for your site. But there's an answer - remove it. The beauty is that removing this code from each page not only makes your page more 'digestible' for search engines but it also makes the maintenance of the JavaScript code easier.
The Two Step Plan 1. Highlight all the JavaScript in your page in between (not including) the <script language="javascript"> and the </script>, and then copy and paste it into a new notepad document (or whatever you use). Save this document as 'scripts.js'. On your web page you should now be left with <script language="javascript" type="text/javascript"> and then </script>. Now all you need to do is add the address of this external JavaScript page into the opening JavaScript tag, something like this:
<script language="javascript" src="scripts.js" type="text/javascript"></script>
This tag now tells the browser that it should go to scripts.js to get all the relevant JavaScript code for the page.
2. Upload the external JavaScript page (scripts.js) to your web site and then replace all the existing JavaScript code in the section of your pages with just the one single line;
<script language="javascript" src="scripts.js" type="text/javascript"></script>
This example assumes that your external JavaScript page and your web pages are all being uploaded into the root directory, if they are not then you will have to check the url of the src="scripts.js" on each page to make sure the JavaScript is working properly.
The advantage of having all your JavaScript on one page is that if you have to make any changes to it you only need to do it once instead of going into every page of your site and making the same change.
If you have two sets of JavaScript code then just do this twice so you end up with the following in your <head> tag:
<script language="javascript" src="scripts1.js"></script> <script language="javascript" src="scripts2.js"></script>
|