-
Notifications
You must be signed in to change notification settings - Fork 27.3k
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
Pages render without styles for a brief second #15642
Comments
This should've been fixed in Next.js 9.5, please upgrade and let us know! Otherwise, please provide a complete reproduction. |
Just upgraded to 9.5. Sorry to say it is still a problem 😕 |
|
However, if I leave my devtools open (where I have disabled cache) - the problem persists. So it might still be a thing on the very first page load? |
@johneas10 Afraid not, still having this issue. Currently running |
Thanks for reopening the issue. Shame you've not come across a solution yet. I'm using styled-components and came across this issue which seems like it might be similar, although I've tried ignoring fonts all together and the screen still flickers. |
@Lillebo I've fixed the issue by following this example with a custom |
That solution requires the use of |
No not at all. I happen to be using |
But the example you're referring to seem to depend entirely on |
Yeah sorry I posted think link as I thought it might be of some help to you, and maybe others. My setup seems to be a little different to yours though. |
Yup, no worries 🙂 |
Can you try adding a This stackoverflow answer seemed to help me. I was getting quite a bit of FOUC in Firefox and it seems to be gone. You'll need to add a custom _document. |
I am having this issue on Might it have something to do with a custom render function in the _document.js where we add the GTM tags and therefor it doesn't load it properly in the head? The SSR works fine as when I run the website without JS, I can see the website without the FOUC problem. But when I enable it, I get everything unstyled first and then rendered properly like the example of OP |
Just want to update this thread that with 10.0.0 this problem still exists |
sam problem with 10 version, any updates :/? |
Closing as there was no full reproduction provided. |
This worked for me, thank you, not sure why... |
All browsers? I read some things about FF only about that solution |
Yes, on chrome. I was focused on chrome first. I am using ant design and the FOUC was breaking my CSS. It would show ellipses instead of a menu. |
Thanks! This worked perfectly for me, but I have no idea why. Can somebody explain? |
I believe this is the issue from Mozilla: https://bugzilla.mozilla.org/show_bug.cgi?id=1404468 |
I am also facing this issue my Next.js version is 9.5.5 and react version is 16.8.6. |
The FOUC still happens on next.js 10, on chrome also. |
I've also come across this bug. Here's a very minimal reproduction. @Timer Will this reproduction be enough? The following results are copied from the README of the reproduction repo:
|
Same here with next 10.0.8 and Chrome 88 on macOS 11.2 Step to reproduce : Go to http://localhost:3000 from chrome and reload page next-fouc.mov |
Hmmm ... the problem still exists. I've added comments to 3 other closed issues taming the same problem. This is very uncomfortable. Not just in this special case but in other cases too. There is an issue, linking to another similar issue, linking to another similar issue, ... so on. All of them closed. So far Nextjs is the worst experience among all frameworks I've been using in the last decade. Not expecting any fixes, I'm just expressing loud my frustration. |
Agree somewhat with @osequi 's sentiment. This issue has been reported multiple times by multiple different people. Every time the issue is closed with a version release referenced, yet the issue remains for all of those who originally reported the issue. It would be better to, upon releasing any potential fix, checking with the original bug reporter to see if their issue has actually fixed or not before closing these issues down prematurely. |
I'm having this issue too and it's not only the styles, I have some hidden element to be show after some JS condition and they render before get hide. It was happening with my root page and so I thought to test add some "land page", first using Since it only happen on production my guess is that a workaround would be disabling the "Automatic Static Optimization" but it is not possible to disable, is it? Edit: So the workaround is changing your page/component return as:
to prevent the Automatic Static Optimization. |
It's June 2021 and I am waiting for an official fix for this issue. |
Did you set up https://github.com/mui-org/material-ui/blob/master/examples/nextjs/pages/_document.js#L53-L61? Because the initial render does not have FOUC from anything injected by Next.js, you're using a material-ui icon that is causing everything to shift around as the styles are not available in the first render. For example the header styles are available immediately. |
Thanks @timneutkens |
I am also having this issue. Iam using next v. 10.2.3 with styled components, using the config described here: The <script>0</script> hack at first sight worked, but when i deployed to vercel, the issue is still happening. |
This FOUC issue persisted, <script>0</script> not working on Next11. Anyone has the solution yet? https://github.com/ansonlowzf/sinno-nextmui5/blob/main/pages/_document.js |
This comment has been minimized.
This comment has been minimized.
Issue is still up, Next.js version v11.0.1, tried <script>0</script> and the _document.js solution mentioned here none have worked thus far. |
Same issue Next.js version v11.0.1, none of the issues worked. I am using Tailwindcss |
Same issue with Next.js v11.0.1, Material-UI with SSR |
Same Here!!! |
I'm still facing the same issue with NextJs v11.0.1 and React v17.0.2 |
Also having the same issue, but using |
Still have same problem here, NextJS
This render problem only occurs after production build. |
Indeed, it seems like the |
@artus9033 Yes I have the exact same setup, I followed Mui5 example with the |
Any solutions? Jan 2022 |
Please open a separate bug report with your reproduction. |
Bug report
Describe the bug
Pages render without any styles for a brief second before the CSS is loaded:
This only happens in production. In development everything is fine and pages render perfectly styled immediately.
To Reproduce
I try to load some global styles in
_app.tsx
like:Then all my pages and components follow this pattern:
Expected behavior
I expect pages to render with styles without such flickering.
System information
The text was updated successfully, but these errors were encountered: