Unfortunately, this feature is (still) stuck behind an origin trial and requires serving three different WebAssembly binaries to get correct fallback behavior across different browsers.<p>Feature detection for WebAssembly[0] is stuck in spec discussions, and SIMD general availability is blocked on either that or its own mechanism for backwards compatibility[1].<p>The issue is that a WebAssembly binary that contains instructions unknown to the engine (e.g. SIMD instructions not supported by a particular engine) won't validate, even if the functions aren't used at runtime. The only way to work around this is to compile your binary NxMx... times and detect which feature set is supported before loading a binary. It's a real pain in the tail when trying to support new WebAssembly features.<p>e.g. check out this snippet from canvas.apps.chrome which supports WebAssembly threads on Chrome with a non-thread fallback for e.g. mobile / Firefox:<p><pre><code> var X;
try {
X = (new WebAssembly.Memory({
initial: 1,
maximum: 1,
shared: !0
})).buffer instanceof SharedArrayBuffer ? !0 : !1
} catch (a) {
X = !1
}
var ua = r(X ? ["js/threads/ink.js", "defines_threads.js"] : ["js/nothreads/ink.js", "defines.js"])
, va = ua.next().value
, wa = ua.next().value;
</code></pre>
[0]: <a href="https://github.com/WebAssembly/conditional-sections" rel="nofollow">https://github.com/WebAssembly/conditional-sections</a>
[1]: <a href="https://github.com/WebAssembly/simd/issues/356" rel="nofollow">https://github.com/WebAssembly/simd/issues/356</a>