There's actually good reasons why scripts *shouldn't* go in the
header:

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

Current best practice is to follow unobtrusive DOM scripting, using
progressive enhancement. This means separating your scripting into a
behavioural layer, just as you separate structure (XHTML) from
presentation (CSS). As behavior is ideally layered on top of
structure, positioning your scripts so that they don't block page load
(at the bottom of the page), and executing them ondomready, and not
writing inline events, are all considered examples of best practices
at this point in web development.

On Mar 18, 8:38 am, MorningZ <morni...@gmail.com> wrote:
> There's no reason why script can't go in the header......
>
> Related to your original question, do you feel anything is gained by
> using
>
> <script language="Javascript" type="text/javascript">
>      google.load("jquery", "1.3.1");
> </script>
>
> over
>
> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/
> libs/jquery/1.3.2/jquery.js"></script>
>
> seems like the second version is one less thing to have to run or
> break
>
> On Mar 18, 9:46 am, Milan Andric <mand...@gmail.com> wrote:
>
> > So all of the javascript code should go at the end of the html doc,
> > right before closing </body> tag? I thought it should go in the
> > header.
>
> > Sorry for the ignorance,
>
> > --
> > Milan
>
> > On Mar 17, 8:22 pm, mkmanning <michaell...@gmail.com> wrote:
>
> > > You don't need the callback, but you can call it with:
> > > google.setOnLoadCallback(init);
>
> > > The domready wrapper is still a good idea though, depending upon where
> > > your scripts are--at the close of the body we hope :)
>
> > > On Mar 17, 2:52 pm, Milan Andric <mand...@gmail.com> wrote:
>
> > > > Hello, I was just adding a dropdown menu to my site using droppy.
>
> > > >http://plugins.jquery.com/project/droppy
>
> > > > And I also use google jdev with google.load('jquery',...).
>
> > > > Droppy requires a bit of code to initialize the dropdown:
>
> > > >         $(document).ready(function() {
> > > >           $('#nav').droppy();
> > > >         });
>
> > > > Now where should that code go when I'm using google.load() ... this is
> > > > the solution I came up with:
>
> > > > ...
> > > >     <script language="Javascript" type="text/javascript">
> > > >         google.load("jquery", "1.3.1");
> > > >     </script>
> > > >     <script src="/media/js/jquery.droppy.js" type="text/javascript"></
> > > > script>
> > > >     <script language="Javascript" type="text/javascript">
> > > >         $(document).ready(function() {
> > > >           $('#nav').droppy();
> > > >         });
> > > >     </script>
> > > > ...
>
> > > > Is this perfectly normal?  Seems like since I'm doing google.load() I
> > > > should have a callback or something.
>
> > > > Just wondering ... thanks!
>
> > > > --
> > > > Milan

Reply via email to