Improving Blazor WebAssembly

Learn about enabling Blazor WebAssembly AOT and exploring PWA support.

Enabling Blazor WebAssembly AOT

By default, the .NET runtime used by Blazor WebAssembly is doing IL interpretation using an interpreter in WebAssembly. Unlike other .NET apps, it does not use a just-in-time (JIT) compiler, so the performance of CPU-intensive workloads is lower than we might hope for.

In .NET 6 and later, Microsoft added support for ahead-of-time (AOT) compilation, but we must explicitly opt-in because although it can dramatically improve runtime performance, AOT compilation can take several minutes on small projects and potentially much longer for larger projects. The size of the compiled app is also larger than without AOT, typically twice the size. The decision to use AOT is therefore based on a balance of increased compile and browser download times with potentially much faster runtimes.

AOT was the top requested feature in a Microsoft survey, and the lack of AOT was cited as a primary reason why some developers had not yet adopted .NET for developing single-page applications (SPAs).

Installation of workload for Blazor AOT

Let's install the additional required workload for Blazor AOT ...