A Practical Guide to WebAssembly Basics
A binary format that lets code written in languages such as C++ or Rust run in the browser at near-native speed.
What is at stake
WebAssembly suits heavy computation such as image processing and simulations, but it is not a replacement for JavaScript.
The playbook
- Use WebAssembly for compute-heavy work
- Keep modules small and lazy loaded
- Measure against a JavaScript implementation
- Handle load failures gracefully
- Watch memory use on mobile
Where it goes wrong
Avoid:
- Rewriting interfaces in WebAssembly
- Large modules on first load
- Assuming automatic speed gains
- Ignoring fallbacks
The numbers behind it
| Measure | Figure |
|---|---|
| Format | a portable binary instruction format |
| Interop | WebAssembly modules are called from JavaScript |
| DOM access | modules access the page through JavaScript |
| Size | modules add to download weight |
Getting outside help
When to hand it over: Bring in help when browser-side computation is a bottleneck.
Where this comes from
- MDN Web Docs — WebAssembly
- web.dev — WebAssembly
The figures and practices above come from the sources listed.
Working on something like this?
We take on Web Design & Development work for teams who want it done once, properly. Tell us what you are building and we will tell you honestly whether we are the right studio for it. Start a project.
Where to go next
Spotted something wrong? Report an error on this page. We correct on the page and say what changed.