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

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

From: Andy Holmes <aholmes84@shaw.ca>
Date: Tue, 18 Nov 2003 13:02:32 -0800
To: ernestcline@mindspring.com
Cc: www-html@w3.org
Message-id: <3FBA88E8.7060002@shaw.ca>

Ernest Cline wrote:
>>[Original Message]
>>From: Andy Holmes <aholmes84@shaw.ca>
>>A couple of people were having a discussion on IRC the other day
>>about  the fact that <script> is used with a 'src' attribute to include 
>>external scripts rather than the link element. It seems to me more 
>>consistent and logical to use <link> for external resources like this 
>>and <script> for in-document scripts, such as <style> and <link> have a 
>>relationship for stylesheets.
>>The only thing that is actually missing for <link> to be properly used 
>>is the 'script' link-type. The 'src' attribute on the <script> element 
>>could probably be deprecated if this link-type was added since it 
>>wouldn't be necessary anymore.
> You know, this element, as it is defined has a number of anomalies
> in it.. First off, the type attribute applies to the both the contents
> and to the accessed resource.  It also interacts differently with
> remote stuff.  Let me give some examples to show what I mean.
> Example 1:
> <script type="image/png" src="example1">
>   So do we show a picture or what?
> </script>
> Example 2:
> <script type="image/png">
>   Is the user agent supposed to try to interpret this as
>   some sort of inline data?
> </script>
> Example 3:
> <span type="text/javascript" src="example3">
>   Does this span element get treated  the same
>   as a script element would?
> </span>

This is why I believe that <link> should be used for external scripts 
and <script> for strictly in-document scripting.

> Based on these three examples, I think we need to 
> redefine how the script element is defined for XHTML2.
> First:
> It needs a different attribute than type to indicate the
> MIME type of the contents for the element.
> This would allow the following to be legal:
> <script datatype="text/javascript" type="image/gif" src="flashing_logo">
>   // And here goes a script that if the UA doesn't support animated GIFs
>   // would try to replicated the effect via scripting.
> </script>

Hmm...I may be wrong, but it seems to me that this would get the same 
(theoretical) effect:

<object data="foo.gif" type="image/gif">
	<script type="text/javascript">

If the browser can't handle "image/gif" it falls back to the content of 
the <object>.

- Andy
Received on Tuesday, 18 November 2003 16:08:03 UTC

This archive was generated by hypermail 2.3.1 : Wednesday, 7 January 2015 15:06:06 UTC