Skip to content

Supporting compressed WASM files #3100

Answered by Liamolucko
stnbu asked this question in Q&A
Discussion options

You must be logged in to vote

How do I fetch and load a compressed file? I see that I can pass a promise, is this the strategy that I want (find an async js function to decompress and wrap it in that)? Like init(gunzip('foo.wasm.gz'))?

That should work, although it doesn't have to be async.

One of the many inputs supported by init is bytes containing a wasm module, which will get compiled and instantiated. More specifically, an ArrayBuffer or a TypedArray (general name for Uint8Array, Int32Array, etc.)

So, to load a compressed WASM file, you have to first decompress the wasm file into raw bytes, and then pass those bytes (or a promise resolving to them) to init.

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Answer selected by stnbu
Comment options

You must be logged in to vote
1 reply
@Liamolucko
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants