3 ms·
I think what the original comment means is that WASM is heavily sandboxed in the browser environment, and cannot interact with the DOM APIs directly. You still
by danielvaughn 2y ago
I think what the original comment means is that WASM is heavily sandboxed in the browser environment, and cannot interact with the DOM APIs directly. You still need JS for that.
- andrewfromx 2y agonot all all. I just have: <script>document.addEventListener("DOMContentLoaded", function() { const go = new Go(); WebAssembly.instantiateStreaming(fetch("/assets/other/json.wasm.gz"), go.importObject).then((result) => { go.run(result.instance); WasmReady('welcome.html'); }); });</script> and <script src="/assets/javascript/wasm_exec.js" class=""> and that's it! Then from go there's nothing I can't do in the DOM.
- pfraze 2y agoDoes wasm provide synchronous access through the perimeter?
- andrewfromx 2y agoWebAssembly itself does not provide synchronous access directly; the interactions with WebAssembly modules in browsers are asynchronous. This is because WebAssembly operations, like module instantiation and function calls, are designed to fit into JavaScript's event-driven, non-blocking model.
- JasonSage 2y agoThe `new Go();` is doing all the JS that you claim to not be doing.
- andrewfromx 2y agobut all my logic that changes the DOM is in go. What am I missing?
- deleted 2y ago[deleted]
- deleted 2y ago[deleted]
- Rohansi 2y agoYour logic still needs to run JS code to change the DOM. You are indirectly relying on JS despite using WASM.
- andrewfromx 2y agook but I have all the advantages of go. I can code my go in a modern way and escape JS traps despite the end result is still using js.
- vrighter 2y agoyour code is not manipulating dom. your code is interacting with a library that manipulates the dom. That library has to interface with javascript. You are still doing all dom manipulation via js, it's just hidden behind the library. If you inlined all functions from that library you'd get code that interacts with js. tldr: no, you can't possibly be doing that. Because an api for it literally, objectively does not exist.
- andrewfromx 2y ago