On 2/6/08, John Campbell <[EMAIL PROTECTED]> wrote: > On Feb 6, 2008 2:06 PM, Michael B Allen <[EMAIL PROTECTED]> wrote: > > Is it considered bad practice to emit scripts within the body of a > > page such as immediately preceeding the form that uses it? It seems to > > work fine but from looking at some random sites I have yet to see an > > example of this. Logically it makes sense to put the JavaScript close > > to where it will be used no? > > The standards nazis will tell you to put scripts in the head. The > performance freaks will tell you to put your scripts as the last > element in the body. Putting javascript in the middle of the page, is > bad practice but can simplify development. So where you put scripts > is up to you... I prefer putting all scripts as the last element in > the body because performance is more important to me than standards > compliance, but I'm not afraid to put them in the middle or inline to > get things done faster.
<snip> > I highly recommend using a js library with a good onLoad event > replacement (my favorite is jQuery). The standard default onload > event sucks because it waits for all images to be downloaded rather > than being a "DOMContentReady" event. Hi John, Actually I'm trying not to use much JavaScript if I can help it. I just need a few functions to help with forms (so far). How about src-ing a .js? I've been looking at random pages and I'm surprised to see that not many pages actually do this. Is there a reason? Mike -- Michael B Allen PHP Active Directory SPNEGO SSO http://www.ioplex.com/ _______________________________________________ New York PHP Community Talk Mailing List http://lists.nyphp.org/mailman/listinfo/talk NYPHPCon 2006 Presentations Online http://www.nyphpcon.com Show Your Participation in New York PHP http://www.nyphp.org/show_participation.php