W3C home > Mailing lists > Public > whatwg@whatwg.org > August 2011

[whatwg] Script tags with src and content

From: Den.Molib <den.molib@gmail.com>
Date: Fri, 05 Aug 2011 00:32:12 +0200
Message-ID: <4E3B1DEC.1040803@gmail.com>
I noticed that the html spec doesn't state what should be done with a 
script tag with a non-empty src attribute *and* content inside.

Per section 4.3.1.3 [1] we just know that 'If a |script 
<http://www.whatwg.org/specs/web-apps/current-work/multipage/scripting-1.html#the-script-element>| 
element's |src 
<http://www.whatwg.org/specs/web-apps/current-work/multipage/scripting-1.html#attr-script-src>| 
attribute is specified, then the contents of the |script 
<http://www.whatwg.org/specs/web-apps/current-work/multipage/scripting-1.html#the-script-element>| 
element, if any, must correspond to putting the contents of the element 
in JavaScript comments'
I think that such content would be ignored: since it has a src tag, it 
would be marked as 'from an external file' and 'The contents of that 
file are the script source', but it could also be considered to be 
external and inline at the same time.

I realised this when looking at the recommended code for embedding 
Google+ [2] (choose a language other than US English). It looks like
> <script type="text/javascript" 
> src="https://apis.google.com/js/plusone.js">
>   {lang: 'en-GB'}
> </script>

The script [3] is too minified to follow, but it looks they are using 
the same tag for including the script and embedding parameters, even 
though they are disobeying a must by doing so. Maybe they have a string 
reason and it's the spec what should allow such use. Either way, a 
clarification in the specification looks good.


1- 
http://www.whatwg.org/specs/web-apps/current-work/multipage/scripting-1.html#inline-documentation-for-external-scripts
2- http://www.google.com/webmasters/+1/button/index.html
3- https://apis.google.com/js/plusone.js
Received on Thursday, 4 August 2011 15:32:12 UTC

This archive was generated by hypermail 2.3.1 : Monday, 13 April 2015 23:09:08 UTC