-
Notifications
You must be signed in to change notification settings - Fork 83
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
SSR - Unstyled / Wrong styled with Audit ? #162
Comments
Did you found a solution? |
Nop, I found à Way to improve but not that much.. |
Ok, so I did a workaround. With custom Next js server, I added with Mobile detect, the fallbackscreenclass in the headers, so I can initialize the grid with the fallback. But even with this hack, it's not working. |
Perhaps to clarify this a little bit for anyone stumbling over this or contemplates using this library, because I see you use lighthouse and I'm currently tasked with optimizing a site for the core web vitals that uses this library as well... When we write modern web applications we want them to be responsive (for mobile/tablet/desktop/toasters), the web has a solution for this for many years in CSS called media-queries:
When you use a modern framework like mui and use their Grid components you would write something like:
In the background this generates CSS with media queries using CSS-in-js (just pseudocode):
This is what a library like react-grid-system should do. Instead this library takes a fundamentally different approach, it uses JavaScript to determine the viewport width, then its Grid/Col components change the inline-style attribute depending on the screen size. Its emulating media-queries in javascript/react. When we attempt to render the page on the server all the CSS will be generated for some screen size, the client renders the page (HTML and CSS first, before JavaScript) in whatever the screen size the library thought it was during the server side render. Once the javascript is loaded and executed and the real device screen size is determined, this library then has to change all the CSS again and the browser does a repaint of all the elements effected by the change. During all of which the user can't interact with the page. You will never know the exact screen size / window size in advance of rendering the page on the server. The Core Web Vitals (which now also effect Google ranking) take heavy emphasis on time to first paint metrics and first to interactive, this library - by design - makes optimizing those metrics impossible. |
I found the issue on my side. I removed the setConfiguration which was too slow to initialize. I kept only what I wanted from the lib and the issue was gone. Keep it light :) |
Issues
Step to reproduce
What did I try
It's impacting the score of the audit.
Any idea ?
Here is some code :
The text was updated successfully, but these errors were encountered: