Sample of client-side Blazor with an improved boot up sequence
This Blazor sample shows how to improve the screen shown during "boot up" of a client-side Blazor application to provide more pleasant user experience with more user feedback about its progress.
You can see this example running here:
The sample builds on various other contributions. For starters, we add a small progress animation based on SpinKit to improve the aesthetics.
Next, we adapt the enhancements in this article that describes a technique for intercepting calls to load the initial DLL assemblies during Blazor's stock boot up process. The original intent is to change the visible DLL file extensions for those scenarios where they are blocked from loading, for example by corporate firewalls.
We build on this technique to provide load status to the user as each DLL assembly is loaded, to give the user some feedback as to the overall boot up progress.
Because the stock Blazor client sample (dotnet new blazor
) doesn't have many DLLs to load, the
boot up screen may actually run relatively quickly (defeating the need for this technique), but
you'll find this useful in larger, more real-world applications that may have many more and larger
CLR assemblies to load.
In order to simulate what you would actually experience with a larger set of assemblies, this
sample has an artificial load delay of 200ms
per DLL built in. And you can adjust this value
or disable it completely with some URL query parameters (see below).
You can adjust various settings of this sample by providing query parameters to play around with the behavior:
dll_min
- the minimum progress bar value, defaults to0
dll_max
- the maximum progress bar value, defaults to25
which is the number of DLLs loaded by this exampledll_val
- the starting progress bar value, defaults to0
before any DLLs are loadeddll_msg
- the initial progress message, defaults toLoading application...
and will get replaced as each DLL is loadedxhr_send_delay_factor
- if > 0, will enable artificial send delay by the factor number of milliseconds per DLL, defaults to100
xhr_send_abort_count
- if > 0, will abort the boot process after that number of DLLs have loaded, useful to take a snapshot of the progress bar working, defaults to0