W3C home > Mailing lists > Public > www-html@w3.org > November 2003

Re: <link> vs. <script> for external scripts

From: Ernest Cline <ernestcline@mindspring.com>
Date: Thu, 20 Nov 2003 12:26:41 -0500
Message-ID: <410-2200311420172641953@mindspring.com>
To: "Lachlan Hunt" <lhunt07@postoffice.csu.edu.au>
Cc: "W3C HTML List" <www-html@w3.org>




> [Original Message]
> From: Lachlan Hunt <lhunt07@postoffice.csu.edu.au>
> 
> ... however, with the use 
> of the DOM and XMLEvents, and the fact that document.write(), or 
> similar, shouldn't be used any more, is there any need to have
> scripts outside of the head element and within the body?

Yes.   I don't use scripting much in my pages,
but I can easily come up with a use case.
Consider the following oversimplified example:
<html><head>
  ...
   <script>
      fooline = new Array();
     function foo () {
       if (fooline.length) {
         for (i,0,fooline.length) {
          fooline[i]();
        }
      }
    }
  </script>
  ...
</head><body>
...
  <p src="bar">
    <script>
      function bar() {
        ...
       }
      fooline.push (bar);
      <noscript>
        We have no bar!
      </noscript>
    </script>
</p>
...
  <p src="baz">
    <script>
      function baz() {
        ...
       }
      fooline.push (bar);
      <noscript>
        We have no bar!
      </noscript>
    </script>
</p>
....
</body></html>

Now what the function foo does depends upon which resources
get loaded. If you make those optional scripts external , one can
even bother to load only scripts that are actually needed.  It isn't
something most documents will need, but it is supported by
current (X)HTML and XHTML2 ought to be able (with the
assistance of styling to replace the presentational attributes
that are being removed) to do anything previous incarnations
of (X)HTML can do, even if may do it differently.

    
Received on Thursday, 20 November 2003 12:26:44 UTC

This archive was generated by hypermail 2.3.1 : Wednesday, 5 February 2014 23:40:10 UTC