🎓 All Courses | 📚 Blazor WASM Syllabus
Stickipedia University
📋 Study this course on TaskLoco

Lazy loading reduces the initial download size of a Blazor WASM app by deferring non-essential assemblies until they are actually needed.

Why Lazy Load

  • The default Blazor WASM download includes all referenced assemblies
  • Large apps can have 5–20MB+ initial payloads
  • Lazy loading ships a small shell that loads DLLs on demand

Configuration in .csproj

<ItemGroup>
  <BlazorWebAssemblyLazyLoad Include="MyApp.AdminFeatures.dll" />
</ItemGroup>

Loading Assemblies in App.razor

<Router AppAssembly="@typeof(App).Assembly"
        OnNavigateAsync="OnNavigateAsync">

@code {
    [Inject] private LazyAssemblyLoader AssemblyLoader { get; set; } = default!;

    private async Task OnNavigateAsync(NavigationContext context)
    {
        if (context.Path.StartsWith("admin"))
        {
            await AssemblyLoader.LoadAssembliesAsync(new[]
            {
                "MyApp.AdminFeatures.dll"
            });
        }
    }
}

Best Practice

Lazy load large, rarely-used features such as admin panels and reporting tools. Keep the core app shell small for fast first load.


YouTube • Top 10
Blazor WASM: Lazy Loading Assemblies
Tap to Watch ›
📸
Google Images • Top 10
Blazor WASM: Lazy Loading Assemblies
Tap to View ›

Reference:

Wikipedia: Lazy Loading

image for linkhttps://en.wikipedia.org/wiki/Lazy_loading

📚 Blazor WASM — Full Course Syllabus
📋 Study this course on TaskLoco

TaskLoco™ — The Sticky Note GOAT