if i'm using jquery library with some plugins can i place all at bottom , just before </body>
or it depends?
are there some situations where library+plugin should place in not at end of not bottom?
if i'm using jquery library with some plugins can i place all at bottom , just before </body>
or it depends?
are there some situations where library+plugin should place in not at end of not bottom?
yes, place at the bottom of the page before </body>
for fastest load time.
http://developer.yahoo.com/performance/rules.html#js_bottom
technically you could put it at the top of the page like Reigel is suggesting, but it locks up the whole page's execution, which is lame. the best idea would be to do it parallely, where you simply add the script as a DOM Node after the DOM has been loaded, if possible (if it doesn't mess up your page):
$( function(){ $( 'body' ).append( '<script src="plugin.js"></script>' ); } );
also, there is seriously a thread on this subject every week. search first.
As much as I know you should move JS from head to the body, as it does not delay of the page rendering itself, but the loading of other external scripts (css). I moved it to the bottom of the page, just to easily find it when looking at the source code..
The real reason behind putting everything at the bottom, right before the </body>
, is so that your pages renders fast.
It is an optimization technique, that allows your page to show up in the browser before everything is loaded, if you put all your javascript at the top, the page will look blank until it has finishing loading the scripts, and the user will feel your site is very slow and probably leave.
So, it doesn't matter where you put it, it will still work, the difference is that you let your visitors, see some content and even click on a link even before all the javascript is loaded.
@Dan Beam: Placing your css at the bottom, might show the first render of the page in a weird way, because the CSS is not yet loaded.