Blazor: Prerendered HeadContent gets replaced on WASM startup even if it is not changed #42527
Labels
area-blazor
Includes: Blazor, Razor Components
feature-blazor-builtin-components
Features related to the built in components we ship or could ship in the future
feature-blazor-wasm
This issue is related to and / or impacts Blazor WebAssembly
✔️ Resolution: Duplicate
Resolved as a duplicate of another issue
Status: Resolved
As the WebAssembly application in browser activates it replaces server-prerendered HeadOutlet content with new (same) content (probably new instances of the DOM objects). Which causes UI flickering if you use HeadContent for injecting CSS links (e.g. to support theme switching).
Expected Behavior
Similar to rendering of regular components, the HeadOutlet should not replace the content if it did not change (in comparison to the server prerendered version).
Steps To Reproduce
Blazor WebAssemblyPrerendered mode (ASP.NET Core Host, server prerendering, ...).
Put a component in MainLayout.razor with some content.
When you start the application, the HeadOutlet prerendered content contains the content from HeadContent (correct).
But as the WebAssembly application in browser activates it replaces the HeadOutlet content with new (same) content (probably new instances of the DOM objects).
Which causes UI flickering if you use HeadContent for injecting CSS links (e.g. to support theme switching).
repro repo: https://github.com/hakenr/BlazorHeadContentPrerenderingFlicker
repro site: https://blazorheadcontentprerenderingflicker.azurewebsites.net/
.NET Version
6.0.6
The text was updated successfully, but these errors were encountered: