Lazy loading
When working with Blazor WebAssembly, one of the challenges is download size. Even though it’s not a big problem, in my opinion, we can do some things to handle the download and loading time. We will get back to this in the Common problems section later in this chapter.
When navigating to a Blazor WebAssembly application, all the DLLs for our application and the DLLs from .NET Framework are downloaded. It takes a bit of time to get everything started up. We can load some DLLs when needed by using lazy loading to solve this.
Let’s say that our application is massive where it has a reporting part. Reporting is perhaps not used every day and not used by everyone, and it would make sense to remove that part from the initial download and only load it when we need to.
To make that happen, the part we want to lazy load must be in a separate project/DLL. In the csproj
file of the Blazor WebAssembly client project, add a reference to the DLL by adding...