1. 9

  2. 1

    What makes webassembly a more compact/faster to download, than JavaScript (for, say, a typical SPA app using React.js) ?

    “… This isn’t shown in the diagram, but one thing that takes up time is simply fetching the file from the server. It takes less time to download WebAssembly it does the equivalent JavaScript, because it’s more compact. WebAssembly was designed to be compact, and it can be expressed in a binary form. Even though gzipped JavaScript is pretty small, the equivalent code in WebAssembly is still likely to be smaller. This means it takes less time to transfer it between the server and the client. This is especially true over slow networks…”

    1. 3

      It’s not really comparable since you can’t compile an SPA to webassembly - the browser APIs react-dom use aren’t present on the client.

      If you’re comparing rust compiled to JavaScript with rust compiled to webassembly, the bytecode format is going to be smaller.