This is Interesting: Free Magazines for Graphics designers and webmasters  


Home > Archive > Stylesheets > August 2006 > Does it matter if Javascript code comes before you DOCTYPE?





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author Does it matter if Javascript code comes before you DOCTYPE?
~john

2006-08-09, 7:14 pm

I'm including files via PHP includes and as of now, the javascript code
is being included before my header... my header contains my doctype.
Does this matter?

~john

Harlan Messinger

2006-08-09, 7:14 pm

[forwarding question from c.i.w.a.stylesheets to c.i.w.a.html since it
has nothing to do with stylesheets]

~john wrote:
> I'm including files via PHP includes and as of now, the javascript code
> is being included before my header... my header contains my doctype.
> Does this matter?

David Dorward

2006-08-09, 7:14 pm

~john wrote:

> I'm including files via PHP includes and as of now, the javascript code
> is being included before my header... my header contains my doctype.
> Does this matter?


Yes. The Doctype must come first.

--
David Dorward <http://blog.dorward.me.uk/> <http://dorward.me.uk/>
Home is where the ~/.bashrc is
Andy Dingley

2006-08-10, 6:38 am

~john wrote:

> I'm including files via PHP includes


So _you_ control the ordering, it's not just some evil imposed on you
by cheapskate hosting.

> the javascript code is being included before my header.


Stop doing that. You control the includes, so fix it.

> Does this matter?


It doesn't (practically) appear to matter to the JavaScript, although
it is strictly speaking invalid.

It certainly does matter to the doctype, which will effectively
disappear. As you're hopefully relying on the doctype to switch the
browsers into a standards-based rendering mode, then this is bad and
needs fixing.

Sponsored Links


Copyright 2003 - 2008 forum4designers.com  Software forum  Computer Hardware reviews