esm.sh icon indicating copy to clipboard operation
esm.sh copied to clipboard

Use WebAssembly.compileStreaming for WebAssembly modules

Open nicolo-ribaudo opened this issue 2 years ago • 2 comments

I was reading the docs, and I noticed this example as a wasm import: https://esm.sh/@dqbd/[email protected]/tiktoken_bg.wasm?module

That code first fetches the wasm code, and then it compiles it. This can be done more efficiently, by compiling the wasm code while it is being downloaded:

export default await WebAssembly.compileStreaming(fetch("https://esm.sh/@dqbd/[email protected]/tiktoken_bg.wasm"));

nicolo-ribaudo avatar Aug 28 '23 17:08 nicolo-ribaudo

@nicolo-ribaudo good to know! would you like to create a PR? or i will do it later, thanks

ije avatar Aug 29 '23 04:08 ije

@nicolo-ribaudo good to know! would you like to create a PR? or i will do it later, thanks

ije avatar Aug 29 '23 04:08 ije