Then along came XHTML. Script tag content could contain entities such as ampersands. Although browsers in HTML mode parsed the content fine, it was not valid XML. So add a CDATA declaration, and you can put any content inside the script tag.
XHTML was seen as the future of the web. It was theoretically faster because browsers could be sure there were no HTML errors before parsing.
In the mid 2000s there was a strange push for uber compatibility and HTML standards guru Ian Hickson proposed an extremely ambitious approach that combined HTML comments with XML comments.
In the late 2000s people started to realize that using XHTML wasn’t really that helpful and that comments weren’t necessary. The type attribute had been optional since the mid 1990s and people started to drop it. So you were left with a bare script tag. How liberating!
And finally we have the way of 2013. In addition to IIFE, we can add the string
"use strict"; to the function body and the code would be error-checked. At development time, potential errors were easy to pinpoint. Older browsers see
"use strict"; as a string literal that is never used; it has no effect. For other browsers, it triggers a mode that will throw errors for such things as missing
- There are also
asyncattributes that can be very useful.
- You might start seeing
"use asm";in addition to
- You may see the
languageattribute come back to support native use of languages like Coffescript and TypeScript.
And who knows what will come up next.