Telling people to add <SCRIPT> only to their heads sounds like reasonable things, but as others have said, there are many reasons why this is not recommended or even practical - basically the speed and way to create dynamic HTML pages.
Here's what the HTML 4 spec says:
The SCRIPT element places the script in the document. This element can appear any number of times in a HEAD or BODY HTML document.
And some HTML sample. Doesn't it look completely formatted here :)
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <HTML> <HEAD> <TITLE>A document with SCRIPT</TITLE> <META http-equiv="Content-Script-Type" content="text/tcl"> <SCRIPT type="text/vbscript" src="http://someplace.com/progs/vbcalc"> </SCRIPT> </HEAD> <BODY> <SCRIPT type="text/javascript"> ...some JavaScript... </SCRIPT> </BODY> </HTML>
And what we look forward to in HTML 5 :
New async attribute in <SCRIPT> :
Note. There are [sic] methods: SCRIPT can be executed:
The asynchronous attribute is true: SCRIPT will execute asynchronously with the rest of the page, so SCRIPT will execute while the page continues parsing.
The asynchronous attribute is false, but the defer attribute is true: SCRIPT will execute when the page ends with parsing.
Simon_Weaver Feb 03 '09 at 6:10 2009-02-03 06:10
source share