Hi Christopher,
> -----Original Message-----
> From: Christopher Schultz [mailto:[email protected]]
> Sent: Saturday, August 8, 2015 2:32 PM
>
> This is a common problem, and the reason for it is that <script> for
> some reason, in every browser I've ever seen, completely fails to
> parse correctly if it's a self-terminating tag like <script />. When
> you use .jspx, the input and output are assumed to be both well-formed
> XML where <script /> is perfectly acceptable.
>
> IMO this is a problem with browsers. Even in standards-compliance
> mode, they seem to demand that <script> be a paired tag. Thus, all of
> our script tags that reference external files are written like this:
>
> <script src="(script)" type="text/javascript"><!-- --></script>
>
> This will force the XML serializer to retain the comment and force a
> paired tag.
Can you elaborate why you think this is a problem with browsers?
The W3 HTML5 specification says at section 4.11.1 [1] for the <script> element:
Tag omission in text/html:
Neither tag is omissible
I read it so that when using HTML syntax (text/html), you cannot omit the end
element of a <script> tag. Section 8.1.2 (Elements) [2] also doesn't seem to
allow a self-closing tag for <script> elements.
However, you can use the XML syntax instead the HTML syntax for serializing
HTML5, which means using a Content-Type of "application/xhtml+xml". When using
this content type, a browser supporting HTML5 (including IE 9+) will use an XML
parser, so a syntax like <script /> will work on such documents.
(The problem with XML syntax however is that there are some JavaScript
libraries that don't seem to be aware that there's an XML syntax of HTML5 and
will not work correctly, e.g. jQuery Mobile up to version 1.4.5.)
Regards,
Konstantin Preißer
[1] http://www.w3.org/TR/html5/scripting-1.html#the-script-element
[2] http://www.w3.org/TR/html5/syntax.html#elements-0
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]