3 ms·
Wow, all that code is needed to feed a string to WebAssembly.instantiateStreaming()? What does the code do? I was hoping there could be a trick like feeding a
by TekMol 6y ago
Wow, all that code is needed to feed a string to WebAssembly.instantiateStreaming()?
What does the code do?
I was hoping there could be a trick like feeding a "blob:..." url to instantiateStreaming() or something.
Since the bottleneck of a codebase typically is a single loop, I think it often would be a good approach to rewrite that one in Webassembly by hand.
- stagas 6y agoYou can inline the binary as base64 or simply a Uint8Array and instantiate it without having to fetch a wasm file. Many choose that approach as it also makes the library `import`-able in sync. The code I was pointing can be used to compile the WebAssembly Text format to binary and instantiate it afterwards on-the-fly, which is useful if you don't want a build step, so skipping the tooling(outside the browser) and also make edits which will then be compiled directly when the file executes. It's an option for experimentation mostly.
- TekMol 6y agoOoohh shit! Now I see that instantiateStreaming() does not accept webassembly in text format. So we need to ship a whole compiler to avoid a build step. Count me out :)
- stagas 6y agoYes, my point was that it's so trivial (and negligible in byte count size) to implement a compiler for the Webassembly text format, as the POC demonstrates, that it's curious why the browser isn't including one so that there isn't the need for extra tooling.