No more modes?
brendan at mozilla.com
Thu Oct 14 10:54:02 PDT 2010
On Oct 14, 2010, at 10:28 AM, Brendan Eich wrote:
> if (this.__MAX_ECMASCRIPT_VERSION__ < 6)
> document.write("<script src='downrev.js'><\/script>");
> document.write("<script src='uprev.js' type='application/ecmascript;version=6'>");
> This is not the best we can do but it is better than user-agent sniffing. And user-agent sniffing is what you'll get if you don't provide some better way.
The problem could be addressed with markup extensions. Today, even in browsers that violate RFC4329 by ignoring ;version= parameters on <script type="..."> type attribute values, the following code "works":
<script src="new.js" type="application/ecmascript-harmony"></script>
But you have to use a novel script type, not standardized by RFC4329 or anything else, for "new.js". And you always load "always.js".
Note how with HTML5's video tag, after <object> and <embed> and other precedents, you can nest fallback content inside the container tag. Alas, the script tag's content model (CDATA) precludes this.
But what if one could write this instead?
<altscript src="new.js" type="application/ecmascript;version=6">
Then we could have no round trips and fallback in the <altscript> container. This would entail no syntax errors, no extra round trips (beyond what current best practices motivate), and no freeze-the-future follies. Comments?
More information about the es-discuss