Boosting PWA Performance with WebAssembly (WASM)
Speed up your PWA (with WASM?)
Web applications are far too slow and offer a poor user experience! These are the main arguments I hear when people want to use native applications. But that is definitely not generally correct.
For mobile apps, you can only really exploit all the possibilities with a native app. Apple and Google provide tools to create excellent apps. However, things look completely different for desktop applications. Apple effectively offers the same developer experience for desktop applications. But on Windows you have an almost endless choice. Even in the Microsoft ecosystem, this is not solved uniformly.
However, as soon as you want to create cross-platform applications, things look completely different. Even though Flutter does a good job, you need to be very familiar with it to really get the most out of your app. And that too with an otherwise unknown programming language, Dart.
Investing in web technologies is a big win. Absolutely cross-platform. Natively in any browser (no matter what platform) or installable as a PWA. There are countless excellent libraries for the UI if you don’t have the confidence to create something yourself with HTML and CSS. And performance is not excluded here either.
WebGL / WebGPU supports very graphics-intensive applications. And with the Graphics Canvas element, there has long been a way to design output beyond the HTML and CSS options.
Computationally intensive operations do not have to run directly in the main application, where they may slow down the flow of the program. That’s what service workers are for. Multi-threading for the browser.
If that’s still not enough for your use case, perhaps WebAssembly is right for you. In particular, computationally intensive functions or complex algorithms can be given a boost by WebAssembly. However, I don’t yet see a clear pattern as to which applications should definitely use WASM.
Even if you can write WebAssembly directly, using a higher-level language is certainly recommended. Including C or C++ and Rust. But AssemblyScript can also be useful because it is very similar to TypeScript. For me personally, Zig is the language of choice.
WASM can also be very useful if you want to share native libraries between different platforms. Both with native counterparts and back-end services. Thanks to the WASI specification, WASM could even be interesting as an alternative to classic containers.
- WebAssembly
- Web Workers API
- Use Cases
- Mozilla Hacks: Standardizing WASI: A system interface to run WebAssembly outside the web
- AssemblyScript
- Zig