Skip to content

Conversation

@BurkusCat
Copy link
Contributor

@BurkusCat BurkusCat commented Aug 7, 2024

Fix loading progress svg CSS positioning. This updated CSS style stops a Cumulative Layout Shift from happening during the render of the default Blazor templates.

Fix Cumulative Layout Shift issue in blank Blazor templates

  • You've read the Contributor Guide and Code of Conduct.
  • You've included unit or integration tests for your change, where applicable.
  • You've included inline docs for your change, where applicable.
  • There's an open issue for the PR that you are making. If you'd like to propose a new feature or change, please open an issue to discuss the change or find an existing issue.

Summary of the changes (Less than 80 chars):
Change the css of the loading circle to use absolute positioning to prevent CLS

Description

The default loading-progress svg has a short height and positioned part way through the page. This is the initial <body> for the page. When the main app loads, the <body> needs repositioned to 0,0 and becomes the full length of the webpage.

The change I've made makes the loading-progress svg positioned absolutely. This means the body tag's location will be 0,0 by default and not impacted by the default loading-progress svg's position. When the app loads this means no cumulative layout shift happens.

Performance tab before Performance tab after
image image
Lighthouse tab desktop before Lighthouse tab desktop after
image image

Cumulative Layout Shift is reduced to 0 for both mobile and desktop. Overall performance score rises to 69 (from 61).

On a live WASM website where I applied this change, the overall performance score rose from 31 to 40 on mobile and 60 to 68 on desktop.

Fixes #57212

This updated CSS style stops a Cumulative Layout Shift from happening during the render of the default Blazor templates.
@BurkusCat BurkusCat requested a review from a team as a code owner August 7, 2024 16:06
@ghost ghost added the area-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates label Aug 7, 2024
@dotnet-policy-service dotnet-policy-service bot added the community-contribution Indicates that the PR has been added by a community member label Aug 7, 2024
@dotnet-policy-service dotnet-policy-service bot added the pending-ci-rerun When assigned to a PR indicates that the CI checks should be rerun label Aug 14, 2024
@BurkusCat BurkusCat closed this Aug 16, 2024
@BurkusCat BurkusCat reopened this Aug 16, 2024
@dotnet-policy-service dotnet-policy-service bot added this to the 10.0-preview1 milestone Aug 16, 2024
@mkArtakMSFT mkArtakMSFT added area-blazor Includes: Blazor, Razor Components and removed area-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates labels Sep 9, 2024
@dotnet-policy-service dotnet-policy-service bot added the area-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates label Sep 9, 2024
@mkArtakMSFT mkArtakMSFT removed the area-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates label Sep 9, 2024
@dotnet-policy-service dotnet-policy-service bot added the area-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates label Sep 9, 2024
@mkArtakMSFT mkArtakMSFT removed this from the 10.0-preview1 milestone Sep 9, 2024
@mkArtakMSFT mkArtakMSFT removed the area-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates label Sep 9, 2024
@dotnet-policy-service dotnet-policy-service bot added the area-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates label Sep 9, 2024
@mkArtakMSFT mkArtakMSFT removed the area-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates label Sep 10, 2024
@MackinnonBuck
Copy link
Member

Thanks for the contribution, @BurkusCat!

@MackinnonBuck MackinnonBuck merged commit 3ec708f into dotnet:main Oct 3, 2024
@dotnet-policy-service dotnet-policy-service bot added this to the 10.0-preview1 milestone Oct 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-blazor Includes: Blazor, Razor Components community-contribution Indicates that the PR has been added by a community member pending-ci-rerun When assigned to a PR indicates that the CI checks should be rerun

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Loading progress .svg in the default Blazor template causes a Cumulative Layout Shift on the <body> tag

3 participants