Hello Scott and all, I prefer to put JS in header, also. But I read somewhere that there is a bug dealing with an interference of PHP's $variables and jQuery $-notation, so it's suggested to put the jQuery functions into the body and not into the head section. Is it true? -- With best regards from Ukraine, Andre Skype: Francophile; Wlm&MSN: arthaelon @ yandex.ru; Jabber: arthaelon @ jabber.org Yahoo! messenger: andre.polykanine; ICQ: 191749952 Twitter: m_elensule
----- Original message ----- From: Scott Sauyet <scott.sau...@gmail.com> To: jQuery (English) <jquery-en@googlegroups.com> Date: Monday, November 30, 2009, 4:41:04 PM Subject: [jQuery] Re: Best Practices or unobtrusive Javascript On Nov 29, 8:21 pm, breadwild <breadw...@gmail.com> wrote: > I have seen several examples on jQuery plugin sites that have the > <script> tag and Javascript within the <body> and not the <head> where > I thought it was supposed to go. "Supposed to go" is a subjective consideration. The rationale for putting it at the bottom of the body is a fairly simple, and fairly persuasive, argument about performance. A nice short version of that is here: http://developer.yahoo.com/performance/rules.html#js_bottom The rationale for putting it in the head is really one about being unobtrusive. If JavaScript is used unobtrusively, then JS is never plain data, but always metadata. And the head is the place for metadata. I almost always choose the latter, because it simply feels cleaner to me. But I'm not dogmatic and if your CMS makes it more practical to put in the body, then go with that. There is one real advantage in jQuery to using the bottom of the body. At that point, the DOM is already loaded, and you can run without putting everything inside a $ (document).ready() function. -- Scott