Description
Is there an existing issue for this?
- I have searched the existing issues
Is your feature request related to a problem? Please describe the problem.
If we have a component that creates an empty diff when re-rendering, i.e. there was no change in the resulting markup, this empty diff is still sent to the server and takes up a certain size in the serialized data.
For example, consider this component:
@Value.DayOfWeek
@code {
[Parameter]
public DateTime Value { get; set; }
}
Render the above component 1000 times:
@page "/"
<button @onclick="@(StateHasChanged)">Render</button>
<br />
@for (var i = 0; i < 1000; i++)
{
<Component Value="DateTime.Now" />
}
Click the "Render" button.
Despite the fact that the resulting markup does not change (it changes once every 24 hours), 12 kB of data is sent to the server:
It can be seen that the data sent is very "sparse":
This particular case could of course be optimized using the ShouldRender method. However, in general it doesn't make sense (at least I think so) to send an empty diff to the client.
Describe the solution you'd like
Modify the int Write(in ArrayRange<RenderTreeDiff> diffs)
method in RenderBatchWriter
to ignore empty diffs.
Additional context
No response