Advertisement
Intermediate .NET, Blazor (Server & WebAssembly)

How does Blazor WebAssembly's initial load performance compare to Blazor Server, and what techniques mitigate WASM's larger download size?

Short answer

Blazor WebAssembly requires downloading the .NET runtime and app assemblies (historically several MB, though significantly reduced by trimming, AOT compilation, and runtime relinking in recent versions) before the app becomes interactive, giving it a slower 'time to interactive'…

Save .NET mock interview
Advertisement
AModel answer
Blazor WebAssembly requires downloading the .NET runtime and app assemblies (historically several MB, though significantly reduced by trimming, AOT compilation, and runtime relinking in recent versions) before the app becomes interactive, giving it a slower 'time to interactive' on first visit compared to Blazor Server's near-instant SignalR-based startup -- mitigations include enabling trimming, lazy-loading assemblies for rarely-used features, and browser caching so repeat visits skip re-downloading.
<PropertyGroup>
  <PublishTrimmed>true</PublishTrimmed>
  <RunAOTCompilation>true</RunAOTCompilation>  <!-- faster execution, larger download -->
</PropertyGroup>

<!-- Lazy loading a rarely-used assembly -->
<BlazorWebAssemblyLazyLoad Include="AdminModule.dll" />
Real-world example
A Blazor WebAssembly app lazy-loads its rarely-used admin module assembly only when an admin user actually navigates to admin pages, reducing the initial download size for the much larger population of regular users.
Likely follow-ups
  • What's the trade-off between AOT compilation's execution speed and its larger download size?
  • How does browser caching (via Cache-Control) help repeat visitors?
Related topics