What is Ahead-of-Time (AOT) compilation in Blazor WASM, and what are the trade-offs regarding file size and execution speed?
Last updated
AOT compiles .NET IL to native WebAssembly at publish (
<RunAOTCompilation>true</RunAOTCompilation>, needs thewasm-toolsworkload) instead of interpreting IL in the browser.Trade-off: much faster CPU-heavy execution (often 2x+), but roughly double the download size and longer publish times.
Worth it for compute-bound apps, rarely for UI/IO-bound ones. Combine with trimming to offset size.
- https://learn.microsoft.com/en-us/aspnet/core/blazor/webassembly-build-tools-and-aot?view=aspnetcore-10.0
- https://learn.microsoft.com/sk-sk/aspnet/core/blazor/performance/?view=aspnetcore-12.0
- https://www.telerik.com/blogs/blazor-basics-exploring-blazor-webassembly-ahead-time-aot-compilation
- https://code-maze.com/blazor-webassembly-ahead-of-time-compilation/
- https://dev.to/prahladyeri/boosting-performance-with-net-8-and-blazor-33dd
- https://blazor.syncfusion.com/documentation/common/aot-compilation/optimize-performance-blazor-wasm
- https://medium.com/dotnet-new/maximize-performance-in-blazor-webassembly-18f81b7989cc
- https://docs.devexpress.com/Blazor/404490/common-concepts/optimize-performance-and-size-of-blazor-wasm-applications