Brendan Eich (2016-01-02T22:28:04.000Z)
mathias at qiwi.be (2016-01-03T11:06:39.694Z)
Thanks, Claude. It may be tempting to assume the standard specified something dumb, or due to "legacy" mysteries. Not so. HTML5 fully specifies <script>, which I created in 1995 at Netscape. I had no time for the src= attribute, and even if I had (I implemented that in 1996 for Netscape 3), but basis case was code directly in the HTML page, as I noted on Twitter: https://twitter.com/BrendanEich/status/683344089308200960. kdex, think about how `<` is interpreted within an inline `<script>` -- it is not escaped via `<` nor can or should it be. Likewise, HTML comments don't work as such in script content. The script element's content model, which I borrowed from SGML in a hurry in late spring '95, is called CDATA. For ease of use, I chose not to require the `<![CDATA[` and `]]>` marked section delimiters from SGML (this was controversial back then! SGML and later XML people actually were angry with me over this design decision). Netscape's HTML parser of the time (Netscape 1 and 1.1, predating JS in Netscape 2; same as in Mosaic) already supported `<!--` and `-->` as HTML comment delimiters, without fully parsing SGML comments in all their glory (see http://www.flightlab.com/~joe/sgml/comments.html). Thus, to help early JS adopters hide inline script content from old (non-JS-supporting) browsers, my "two-way comment-hiding hack" was born in Netscape 2. I did require something like this: ``` //--> ``` as the last line of the script content, not wanting to make `-->` yet another comment-till-end-of-line special case. However, IE implemented support for just `-->` (no `//` in front to hide the otherwise-invalid JS syntax) at some point while cloning JS prior to ECMA-262 Edition 1. The Ecma TC39 group only got around to specifying all of this in ES6 Annex B. Often enough, things are the way they are for good reasons. See "Chesterton's Fence".