Closed ludovic-lambert closed 3 years ago
Hey @ludovic-lambert :wave:, Thank you for opening an issue. We'll get back to you as soon as we can. Please, consider supporting us on Open Collective. We give a special attention to issues opened by backers. If you use Loadable at work, you can also ask your company to sponsor us :heart:.
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 (https://github.com/facebook/react/issues/16938 / https://github.com/atlassian-labs/react-loosely-lazy/issues/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. I'm not using Suspense at all. The CLS increases whatever the code after is, even without any dynamically imported component.
With the exact same configuration, the CLS increase is high even if I import everything statically :
import Login from '../Account/Login'
If I import some components dynamically, the CLS increase is slightly higher or the same :
const Login = loadable(() => import('../Account/Login'), { ssr: true, fallback: <SpinLoader /> })
FYI <SpinLoader />
is nothing else than a div with CSS :
import React from 'react'
export const SpinLoader = () => {
return (<div id="spinLoader" className="spinLoader"></div>)
}
export default SpinLoader
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 Performance
tools/record page load in order to find this "shift".
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 , Unfortunately not. Because of this issue and #726 , I've given up trying to use Loadable Component on my project.
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: