View Full Version : change onload to something else?

04-17-2007, 06:39 AM
Here is the code I have on my index page in the header:

<SCRIPT language=JavaScript src="keywords.js" type=text/javascript></SCRIPT>

The very first line of "keywords.js" is:
window.onload = function() {

So here is my question:

How do I go about changing the first line of keywords.js.

shouldn't I change window.onload to something else???

or should I keep it the same?

It's just that right now, my pages are loading slowly.

Thanks in advance.

04-17-2007, 08:18 AM
I doubt that it is the Javascript making your script run slowly.

Maybe you have lots of images on your page, or dynamically generated HTML or maybe a slow server. Check these out and report back if there is still a problem. Include the script you are using and a link to the page too (If online)

04-17-2007, 08:45 AM
It is better if you use a layout which is purely CSS based rather than a table based page layout.

As Bob said reduce the usage of big image/movie/music file in the web page.

04-17-2007, 04:28 PM
I'll work on getting rid of unnecessary files and images.

But most of the stuff I have on my website has to be there.

Isn't there a function that will work before the page loads?

instead of:
window.onload = function() {

04-18-2007, 03:35 AM
Have a look at the following code from which you can learn the execution path of the scripts in a web page.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script type="text/javascript">
//This example shows the which programming statements or function calls exectues in a one by one fashion
alert('Standalone alert statement; the first statement in the script tag');

function callMe()
alert('Inside the callMe function');

//onload event assignment.
window.onload = function () {
alert('inside the onload event');

//Invoking the callMe function


Please let me know if you have any problem with the above code.