What can run in the browser besides JavaScript? WebAssembly explained

Published · Updated

Save

WebAssembly gives a browser a standard binary format for modules that can be compiled from languages such as Rust or C. It is useful when you want to reuse existing code or isolate a computational task.

Understand the browser boundary

A WebAssembly module can export a function for the application to call. It relies on host interfaces for capabilities such as browser APIs. A common design uses JavaScript for the DOM, events and fetching, with a compiled module for a well-defined calculation.

Test whether it fits your app

For image processing, compare the same input and algorithm in JavaScript and WebAssembly. Measure module download and startup, computation, and the cost of transferring data across the boundary. Check the end-to-end user delay on the devices you support before choosing a design.

References

MDN WebAssembly concepts

MDN JavaScript interface

Discuss this answer