Blazor Initial Loads & Latency Tradeoffs. Solved with Blazor United!
Blazor will get a Super Cool Performance Boost in .NET 8+
While working with Blazor Server, every interaction is sent to the server, which then figures out what to change in the DOM, and sends back a delta to the client. The client then uses the delta and makes the required changes on the DOM to give you an updated page without a reload. The major tradeoff with Blazor Server is that there is a significant and eventual lag that may come into play when the client waits for a response from the server depending on various factors.
Blazor WebAssembly solves this latency issue by keeping all interactions on the client side. But at the same time, introduces another tradeoff of having to download all the DLLs to your browser. This is pretty evident. It takes quite a while to load up a mid-sized Blazor WASM project, over 10-20 seconds (although there are indirect workarounds to reduce this a bit).
But, you really need to have both of these capabilities in a single project depending on what an individual page may need. Some pages of your app will need server-rendered HTML and some other parts may require a WASM style of low-latency interactivity.
Blazor United, as announced by Microsoft will leverage both the Blazor Server and WASM concepts and make Frontend Development with C# even more intuitive. I was watching a recent YouTube video from @stevensandersonuk (https://www.youtube.com/watch?v=48G_CEGXZZM&t=635s) where he introduces the super capabilities of Blazor in .NET 8 in a very early prototype.
Of the many features demonstrated, the coolest one was the ability to use both the Server and WASM concepts in the same Blazor Project, even on the same page based on developer demand, or even let the system choose it for you using the Auto mode!
So, by setting the ComponentRenderMode to Auto, with the first load of the application, the page uses the Server rendered HTML and does not have to wait for the WASM-related files to be downloaded into the browser. But it downloads the required WASM Dlls in the background and gets cached. This way, the next time the user reloads the application, it essentially loads up blazor wasm files for super latency-free interaction. This has been a trending approach followed in the FrontEnd industry to enhance the user experience to a truly SPA mode. How cool is this?
Since these are early prototypes, I am not entirely sure if this will make it into .NET 8 release (scheduled for November 2023). However, this is going to up the game for a Blazing fast Frontend experience with C#! What do you think of this?
Looks like BlazorHero can get an update!