-
-
Notifications
You must be signed in to change notification settings - Fork 385
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
React Loadable Components increase Cumulative Layout Shift (CLS) #725
Comments
Hey @ludovic-lambert 👋, |
There is no way I can help you with the information provided, however, I can ask you one question, which might lead to the root cause - are you using sync or async (Suspense) version? Suspense powered loadable might cause CLS in React > 16.10 (facebook/react#16938 / atlassian-labs/react-loosely-lazy#46) It is not "visible" to the eye, but all your content will be removed and instantly placed back. |
Hi Anton, thank you for your help. With the exact same configuration, the CLS increase is high even if I import everything statically :
If I import some components dynamically, the CLS increase is slightly higher or the same :
FYI
|
In this case I've run out of ideas. And without an example is unable to move forward. The only thing you have to check - that there are no hydration warnings and/or CSS is loaded in the correct order. You can use |
What kind of exemple can I provide? Have you try to reproduce with any application? |
I don't have extra time even to go and merge a few awesome PRs here, so no, I have not. And you are the first one who reported the issue, so there is still a chance that it is somehow bound to your particular usecase. |
It takes 3 minutes to switch SSR from Loadable-components to a standard React. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
Hi @ludovic-lambert , I am having the same problem as you. The Loadble component has definetely impacted cls negatively. Have you found a solution to this issue? |
HI @anilturan , |
I guess I'll have to remove it too. Thank you for helping. |
After migrating a server side rendering React application to Loadable Components for code splitting and lazy loading, the initial bundle size, thus its download time, reduced as expected.
However after replacing the classical React rendering method by the Loadable Components one, with the rest of the application code unchanged, my Cumulative Layout Shift score in PageSpeed / LightHouse raised to the sky, from 0.01 to 0.6 or more.
What I am doing wrong?
SSR code before Loadable Components (good CLS score) :
Server-side :
Client-side :
SSR after Loadable Components (bad CLS score) :
Server-side :
Client-side :
Highlights:
<main>
section that is shifted, like if the SSR page is fully rendered dispite usinghydrate
.Config:
The text was updated successfully, but these errors were encountered: