Jump to content

Recommended Posts

Posted

I have a couple of questions about placing javascript:

 

1 - Do you place your javascript, in the head section or at the bottom of the page?

2 - Why do you prefer this choice of placement?

Posted (edited)

Thanks Eric.

 

I have a lot of JS on an index page for a drop down menu and a big slider with text and images.

 

So if the page loads quicker with the JS at the bottom what happens to the functionality of say the menu if someone clicks on it before the JS has loaded?

 

Also, why do you say "If you can"?

Edited by virtual
Posted

Hello, thats why I say if you can. So for your menu you can't (or proabably shouldn't). For menus and things that may need to work immediatly, then in the head is probably nessesary. But for things like form enhancment (non critical stuff) then place those at the bottom. I'm anal, so usually if I can't put them all at the bottom (keep them together) then I don't put any at the bottom. If you google speed up web page download, that suggestion should be top on the list.

Posted (edited)

OK thanks, I won't bother because the page load speed is perfectly acceptable. The site is fairly image heavy (essential to the site and all optimized for web) so I think it is that which is slowing it down slightly, rather than all the JS files.

Edited by virtual
Posted (edited)

virtual, try the site at this link: http://www.websiteoptimization.com/services/analyze/

 

You could try it both ways and see if it makes a difference.

 

There is also a Yahoo! service which will assist by measuring the parts of the page that are slowing you down, but I'll need a bit of search time in order to provide a link. I seem to have lost it. I go search right now.

 

http://developer.yahoo.com/yslow/

Edited by jlhaslip

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...