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
Svyatoslav Kuzmich [JB]
12/17/2023, 3:04 PM
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
Stefan Oltmann
12/17/2023, 6:13 PM
But why does it need a server? Can't JavaScript load WASM locally?
s
Svyatoslav Kuzmich [JB]
12/17/2023, 6:37 PM
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
Stefan Oltmann
12/17/2023, 6:57 PM
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. 🙂