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

[whatwg] Script tags with src and content

From: Tab Atkins Jr. <jackalmage@gmail.com>
Date: Thu, 4 Aug 2011 16:05:05 -0700
Message-ID: <CAAWBYDCHMk1xdHa6qRe2-Vp_rpB3QXCVToMUMNajvycvjXdsYw@mail.gmail.com>
On Thu, Aug 4, 2011 at 3:32 PM, Den.Molib <den.molib at 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
Received on Thursday, 4 August 2011 16:05:05 UTC

This archive was generated by hypermail 2.4.0 : Wednesday, 22 January 2020 16:59:35 UTC