3 ms·
Will there be any advantage to generating asm.js over WebAssembly+polyfill for clients that don't support WebAssembly natively?
by cpeterso 11y ago
Will there be any advantage to generating asm.js over WebAssembly+polyfill for clients that don't support WebAssembly natively?
- TazeTSchnitzel 11y agoThe polyfill is slower.
- magicalist 11y agoIt really depends on what you mean by "slower". Emscripten already supports the "Emterpreter"[1], which uses a straight bytecode (not AST, like webassembly) version of your asm.js code that can be downloaded and parsed quickly while the much more verbose asm.js code is still downloading and being parsed. So while it does more work, it's responsive sooner. If fast start up time is the top priority for your app, the polyfill could easily be the best choice (and there are probably more tricks to be done with incremental parsing by feeding the JS engine wasm -> asm.js code in chunks while running an interpreter in the meantime, prioritizing hot functions in the wasm stream). [1] https://blog.mozilla.org/research/2015/02/23/the-emterpreter-run-code-before-it-can-be-parsed/ https://blog.mozilla.org/research/2015/02/23/the-emterpreter...
- sunfish 11y agoThe polyfill generates essentially the same asm.js code, so it runs at a similar speed. The slowdown is a translation delay at startup. On the other hand, WebAssembly code is smaller than asm.js code, so it downloads faster, so in some situations the polyfill is actually faster.