yield
introduces new syntax to JavaScript. You won't be able to use yield
unless you have specified that you want the new JavaScript syntax, by including a version number in the script type
attribute(*).
When you specify a script version, only browsers that support the given version will execute the block at all. So only Firefox, and not IE, Opera or WebKit, will execute the top block in:
<script type="text/javascript;version=1.7">
function x() {
yield 0;
}
var canyield= true;
</script>
<script type="text/javascript">
if (!window.canyield) {
// do some fallback for other browsers
}
</script>
(*: note that the type and version specified in the type
attribute exclusively determines whether external scripts are fetched, executed, and the mode for the execution. The Content-Type
of a script is, unfortunately, completely ignored.)