Skip to content

Instantly share code, notes, and snippets.

@toolsley
Forked from 140bytes/LICENSE.txt
Last active August 29, 2015 14:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save toolsley/f7f645f1f2a0a6dd6084 to your computer and use it in GitHub Desktop.
Save toolsley/f7f645f1f2a0a6dd6084 to your computer and use it in GitHub Desktop.
function () {
var a = function () { // valid asm.js module
'use asm';
function b() {
return+0
}
return{b: b} // export method
}(); // create the module
return!('prototype'in a.b); // and check whether the exported function is JS or native
}
function(){var a=function(){'use asm';function b(){return+0}return{b:b}}();return!('prototype'in a.b)}
isAsmJsSupported
Written in 2014 by Toolsley
To the extent possible under law, the author(s) have dedicated all copyright
and related and neighboring rights to this software to the public domain worldwide.
This software is distributed without any warranty.
http://creativecommons.org/publicdomain/zero/1.0/
{
"name": "isAsmJsSupported",
"description": "checks whether the browser can compile asm.js modules",
"keywords": [
"asm.js",
"detect",
"support",
"compile"
]
}
<!DOCTYPE html>
<title>Is asm.js supported by this browser?</title>
<div>Is asm.js supported by this browser?</div>
<div>The answer is: <b id="ret"></b></div>
<script>
var isAsmJsSupported = function(){var a=function(){'use asm';function b(){return+0}return{b:b}}();return!('prototype'in a.b);}
document.getElementById("ret").innerHTML = isAsmJsSupported() ? "Yes!" : "No.";
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment