Skip to content

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

@BurkusCat

Description

@BurkusCat

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

  • Default loading bar 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
  • In dev tools performance monitor, you can see that when the loading bar is removed and the main content of the app loads, a "Cumulative Layout Shift" is caused.
  • Google Chrome Lighthouse and https://pagespeed.web.dev/ also identify this as a CLS.
  • Although in this case I don't think it noticeably impacts performances or the user experience, dev tools and Google identifying it mean it could hurt SEO performance. (Blazor apps will have a lower overall "Performance" score in lighthouse if they have this CLS).

Expected Behavior

The default Blazor templates do not have any Content Layout Shifts when loading. A default Blazor app should have a perfect CLS score in lighthouse.

Steps To Reproduce

https://github.com/BurkusCat/BlazorClsTest

  1. Create a blank Blazor WASM project
  2. Launch the application in Chrome/Edge
  3. Open devtools and go to the Performance tab
  4. Press the "Start profiling and reload page" button
  5. Observe a cumulative layout shift:
    image

Lighthouse test:

  1. Launch the application in Chrome
  2. Open devtools and go to the Lighthouse tab
  3. Configure your test for which device you want and press "Analyse page load"
  4. Observe a poor CLS score:
    image

Exceptions (if any)

No response

.NET Version

8.0.303

Anything else?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-blazorIncludes: Blazor, Razor Components

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions