-
Notifications
You must be signed in to change notification settings - Fork 10.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Avoid completely replacing the DOM when Blazor components are re-rendered after prerendering #42561
Comments
Thanks for contacting us. We're moving this issue to the |
Yes yes yes. This is long overdue my guys 🙏😍😇 |
Great to see this is finally being worked on. Let's hope it doesn't get pushed off any longer. |
You can refer ilovedotnet for this issue. The site is built from scratch using blazor wasm and the site also facing flicker issue when it gets loaded. The site has prerendering enabled during publish time in the pipeline. When the site loads the prerendered screen appears and when the blazor engine kicks in, there comes a flash and screen appears after that. |
Thanks for contacting us. We're moving this issue to the |
Thanks for contacting us. We're moving this issue to the |
Following |
Also interested in this. We're building a consumer facing web app & the flicker is very noticeable. |
This one hurts pretty badly with .NET 8 if you have SSR with any kind of interactivity somewhere |
Agreed. Without making this transition seamless, SSR is pretty useless right now. This is a must-have to compete with the competitors in the market. |
And now I've simply replaced the WebAssembly interactivity with HTMX. What a cobbled mess Blazor has become. |
Right now, after prerendering we replace the entire contents of the prerendered component with a fresh DOM copy created from scratch. This has several bad side-effects like:
Instead of replacing the contents of the DOM wholesale, we can do a best effort to reconciliate the DOM with the new rendered DOM when we are trying to apply the render batch.
In an ideal scenario, a developer should be able to produce exact prerenders, meaning that the render after prerendering is identical to the prerendered one.
In that case, the renderer would only need to "attach" event handlers to the appropriate nodes, leaving everything else the same.
The renderer does not have to be perfect and handle all possible scenarios, it can impose strict limitations and "bail out" if it can't figure out how to reconcile a given DOM subtree by replacing that node wholesale.
For example, the render can impose a strict order, suggesting that DOM children nodes in a given subtree must appear in the same order as the prerendered node (in other words, the renderer won't search for them, but iterate in order). A similar restriction might be imposed on attributes (which is not rare, since attributes are emitted in compilation order, except for splatting). Things like
@key
could be leveraged during prerendering too to offer a bit more flexibility in the ordering.In general, this will likely result in a much higher node reuse and will give the developers the chance to always get this right.
The text was updated successfully, but these errors were encountered: