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

> [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