Placement of Script files...

Having problems with DHTML Menu? There is usually somebody here who knows the answer.
Post Reply
vikenk
Mega Advanced
Mega Advanced
Posts: 297
Joined: Tue Nov 29, 2005 7:38 pm

Placement of Script files...

Post by vikenk »

Hello everyone,

In theory, can I place the menu script files anywhere on the page or must I place it as the first item in <body> ot put in in the <head>?

Ever since I implemented the menu, the home page of the website is taking a long time to load. I first I suspected that it may have something to do with images and JavaScipt since the home page is a little image and script heavy. However, there's nothing different about the page except the menu.

I suspected that it had to do with the 30k size of the mmenudom.js file, which had to be parsed before the rest of the page. So, as an experiment, I moved the menu script files to the last item in the page, just before the body close tag. Now the page initially loads faster. The menu is last to show up, but the user at least has something to see and read until the menu shows up, even though it doesn't take long. The home page was just taking too long to show up, and I have a hi-speed connection!

However, I'm not sure if there's any issue that I don't know about with putting the menu last. Is there anything that I need to know about putting the menu last, So far it seems to operate well. The menu would only be last on the home page, since all the other pages respond much quicker.

Thanks.

Viken K.
User avatar
Ruth
 Team
 Team
Posts: 8763
Joined: Thu May 15, 2003 5:02 am
Location: Yucaipa, CA
Contact:

Post by Ruth »

Hi,

I've seen others place it at the bottom for timing reasons or something. It is recommended that it be immediately after the body tag, and I don't know how putting it at the bottom might affect all browsers.

By the way, I keep getting an error message when the page loads

Code: Select all

Error: runMe is not defined
Ruth
vikenk
Mega Advanced
Mega Advanced
Posts: 297
Joined: Tue Nov 29, 2005 7:38 pm

Post by vikenk »

Thanks for replying Ruth. I'll try keeping the script files on the bottom and monitor if there are any problems.

Thanks for pointing out the error. Runme() was a body onload command that I used in the left frame of the site to load a scolling news-ticker script. I don't use it anymore and forgot to take it out. This new ticker that I'm using now, called Memory Ticker (a freeware script), is really nice because it remembers where it was when you leave a page and continues from that point when you go back to the page.

Thanks.

Viken K.
Post Reply