[whatwg] Script tags with src and content

2011-08-04 Thread Den.Molib
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



Re: [whatwg] Script tags with src and content

2011-08-04 Thread Tab Atkins Jr.
On Thu, Aug 4, 2011 at 3:32 PM, Den.Molib den.mo...@gmail.com wrote:
 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.

Yes it does.  You ignore the contents, and only run the @src script.
Look at 
http://www.whatwg.org/specs/web-apps/current-work/complete/scripting-1.html#execute-the-script-block
- step 2 - If the load was successful - step 1.  The substep for
script was loaded from an external source comes before the script
was inline step.


 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.

They're going against a must-level requirement, but the meaning is
easy - they're just using it the inline contents to store data that
the script will grab when it runs.

~TJ