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? Quote
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. Quote
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 Quote
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. Quote
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 Quote
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 Quote
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. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.