Back to Devexpress

Optimize Performance of a Blazor WASM Application

blazor-404490-common-concepts-optimize-performance-and-size-of-blazor-wasm-applications.md

latest2.5 KB
Original Source

Optimize Performance of a Blazor WASM Application

  • Jan 20, 2026
  • 2 minutes to read

Use the ahead-of-time (AOT) compilation feature to optimize the performance of your Blazor WebAssembly application at the expense of a larger application size.

How AOT Compilation Works

Browsers use an IL interpreter to run Blazor WebAssembly applications. Interpreted code is generally slower than Blazor Server applications. On the other hand, you can use ahead-of-time compilation on a developer machine or build server to produce native WebAssembly code. Browsers on client machines can then leverage native WebAssembly code execution for optimized performance. Refer to Microsoft documentation for additional information on AOT: Ahead-of-time (AOT) compilation.

Enable AOT Compilation in an Application

Blazor WASM projects disable ahead-of-time compilation by default. To enable this feature, invoke the project’s context menu and choose Edit Project File :

In the invoked file, set the RunAOTCompilation property to true as follows:

xml
<Project Sdk="Microsoft.NET.Sdk.BlazorWebAssembly">
  <PropertyGroup>
    <TargetFramework>net7.0</TargetFramework>
    <RunAOTCompilation>true</RunAOTCompilation>
    <!-- ... -->
  </PropertyGroup>
  <!-- ... -->
</Project>

Visual Studio initiates AOT compilation only after you publish a project. To do this, right-click your project in Solution Explorer and choose Publish :

You can also execute the following command in the .NET CLI:

console
dotnet publish -c Release

Performance Tests

This section illustrates how ahead-of-time compilation affects application performance. We measured a Blazor Grid that renders 5000 cells and performs various operations in a WebAssembly application:

OperationAOT DisabledAOT Enabled
DxGrid: Filter 100k rows220 ms117 ms
DxGrid: Navigate Between Pages900 ms570 ms
DxGrid: Select a row320 ms80 ms
DxGrid: Sort 100k rows1000 ms950 ms
Switch to another web page735 ms420 ms