views:

22

answers:

2

with many things we do we reference external jquery plugins in the head and do things in the head like $(document).ready ..... We'll we are using ONE CMS that does link Jquery proper in the head itself, but we can't put anything in the head ourselves and just in the the body.

My question with regards to javascript animation and other issues what are the side effects/risks and gotchas of doing loading jquery plugins and code inside the body and whether $(document).ready can be trusted there

A: 

It is best practice to include javascript at the bottom of your document:

http://developer.yahoo.com/performance/rules.html#js_bottom

Matthew J Morrison
A: 

Yes you can put your javascript code at any part of the page but as a convention it should go in head tags but Yahoo performance article and SEO insist that javascript code should go at the bottom of the page.

So you should/can put your javascript code at the end of the page.

Sarfraz
the example of what we are using seems to do $(window).load(function()... ) .. so if we make sure our JS is at the bottom of the body then it should be ok, and there shouldn't be any weird timing issues where it blows up because its trying to run against swomething that hasn't been loaded yet?
klumsy
@klumsy: Yeah that's true with `$(window).load` you have everything loaded in the page by the time.
Sarfraz