I'm curious: Shouldn't my `productionExecutable/in...
# webassembly
s
I'm curious: Shouldn't my
productionExecutable/index.html
still function properly if I open it directly in the browser locally? Is a hosted server necessary for WebAssembly (WASM)? I had the impression that everything should occur within the browser without the need for a server. 🤔
s
Yes, you need a server, like with a regular HTML + JS. When Wasm is added, your HTML loads JS, and that JS in turn loads Wasm. I usually click on IDE browser icons at the top, it spins out the server for me.
s
But why does it need a server? Can't JavaScript load WASM locally?
s
I think I was wrong. The issue is that we are doing the runtime JS
fetch
of a local
.wasm
file, that browsers don’t allow (without a flag, like
--allow-file-access-from-files
in chrome). If we encoded wasm file inside JS, you’d be able to load it locally. It seems that ESM integration proposal could help with loading wasm as well.
s
Can I add this
--allow-file-access-from-files
somehow? I think it would be cool if my WASM app would only run offline completely from a local file. 🙂
🤷 1