Can WASM access the DOM without any JavaScript?

In the WebAssembly Minimal Viable Product the only way to call into and out of WebAssembly is through imports and exports. In the future, WebAssembly may gain capabilities which allow the embedder expose APIs directly, in a browser embedding this could include the DOM.

Imports and exports aren’t very complicated though: from your C code’s point of view they just look like an extern call, similar to a DLL on the Windows platform. You’d likely compile the C code using Emscripten, see its documentation “Call JavaScript functions from C/C++” for details on how this works (since this isn’t the question you’re asking, but I’m guessing it’s the next question).


It’s not clear from your question if you:

  1. Want to compile C code and run it within WebAssembly inside a browser.
  2. Want to compile C code and run it within WebAssembly outside a browser.

Or both.

Leave a Comment