chapter eleven
This chapter covers
- Creating a WebAssembly text format version of a module
- Compiling the text format code into a binary module using the WebAssembly Binary Toolkit’s online tool
- Linking the Binary Toolkit’s generated module to an Emscripten-generated module
- Building the HTML and JavaScript for the UI aspect of a game
WebAssembly is designed with a binary file format so that the WebAssembly files are as small as possible, allowing for fast transmissions and downloads; this doesn’t mean it’s a way for developers to hide their code. In fact, quite the opposite is true. WebAssembly is designed with the web’s openness in mind. As a result, a text format equivalent of the binary format also exists.
The text format allows browser users to inspect a web page’s WebAssembly in much the same way that they’d inspect JavaScript. The binary format’s text format equivalent is also presented for debugging in the browser if the WebAssembly module doesn’t include source maps, as highlighted in figure 11.1.
Figure 11.1. Developer tools in Firefox, with a breakpoint placed in the _ValidateName function of the WebAssembly module you built in chapter 4, section 4.1