Using ahead-of-time (AOT) compilation
By default, Blazor WebAssembly apps use a .NET Intermediate Language (IL) interpreter when running on the browser. Ahead-of-time (AOT) compilation allows you to compile your .NET code into WebAssembly before deployment. Since compiled code is more performant than interpreted code, your app will run faster. The only downside to using AOT is that the app may be larger and, therefore, will take more time to load during application startup.
These are the steps to enable AOT:
- Right-click the project in the Solution Explorer and select Properties from the menu.
- Enter
AOT
in the Search properties textbox. - Check the Use ahead-of-time (AOT) compilation on publish checkbox.
Once AOT is enabled, AOT compilation will occur every time the project is published. It takes much longer to publish an app using AOT compilation, but it can make the Blazor WebAssembly app run much faster. This is especially true for CPU-intensive...