virtual Posted December 10, 2009 Report Posted December 10, 2009 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?
PicnicTutorials Posted December 10, 2009 Report Posted December 10, 2009 If you can, it makes for faster loading pages if you place them at the bottom. When the browser hits a script, it must dowload it before it moves on to the rest of the page.
virtual Posted December 10, 2009 Author Report Posted December 10, 2009 (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 December 10, 2009 by virtual
PicnicTutorials Posted December 10, 2009 Report Posted December 10, 2009 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.
virtual Posted December 10, 2009 Author Report Posted December 10, 2009 (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 December 10, 2009 by virtual
jlhaslip Posted December 10, 2009 Report Posted December 10, 2009 (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 December 10, 2009 by jlhaslip
virtual Posted December 11, 2009 Author Report Posted December 11, 2009 Thanks for the links Jim, very interesting to see the analysis of sizes for each element.
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now