[whatwg] Script tags with src and content

Den.Molib den.molib at gmail.com
Thu Aug 4 15:32:12 PDT 2011


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



More information about the whatwg mailing list