FOUC only in production on latest Firefox
See original GitHub issueWhat version of Next.js are you using?
10.0.7
What version of Node.js are you using?
12.8.3
What browser are you using?
Firefox 85.0.1 (64-bit)
What operating system are you using?
Pop_OS! 20.04 (Ubuntu 20.04)
How are you deploying your application?
Vercel
Describe the Bug
I see a FOUC when accessing my production deployment on Firefox:
It seems to disappear when using Chrome or Firefox on mobile.
I also appear to get the same issue for my portfolio website on Firefox:
Expected Behavior
There should be no FOUC.
To Reproduce
- Visit my production deployment.
- See FOUC.
Or, to reproduce locally:
- Clone this repository.
- Install dependencies (using
yarn
). - Start a development server (using
yarn dev:next
). - Visit http://localhost:3000 and see FOUC.
You’ll need some env
files for that reproduction to work correctly. Instead, you can just reproduce the same FOUC using my portfolio website (which is a lot smaller than that repo anyways):
- Clone this repository.
- Install dependencies (using
yarn
). - Start a development server (using
yarn dev
). - Visit http://localhost:3000 and see FOUC.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:13
- Comments:16 (10 by maintainers)
Top Results From Across the Web
Various websites like GitHub load with flash of unstyled ...
Hi! I've just disabled my extension S3.Translator and then loaded the webpage https://wiki.mozilla.org/Release_Management/Calendar and it solves the problem.
Read more >Flash of unstyled content (FOUC) in Firefox only - Stack Overflow
In my case the reason of FOUC in FF was the presence of iframe on page. If I removing iframe from markup then...
Read more >Local 3 News - APP OF THE DAY: Firefox Focus is a web... | Facebook
APP OF THE DAY: Firefox Focus is a web browser app that gives you less clutter as ... of tabs open on Chrome...
Read more >Firefox Fast & Private Browser - Apps on Google Play
Get the people-first browser that's backed by a non-profit. It's a new era in tech. Don't settle for a browser produced by giant, ......
Read more >Mozilla - Wikipedia
The Mozilla community uses, develops, spreads and supports Mozilla products, thereby promoting exclusively free software and open standards, with only minor ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
After some investigation, I think there are a couple of bugs at play here:
node.js:354
Mozilla devtools source file (specificallyview-source:resource://devtools/server/actors/inspector/node.js
):Any other extension that updates the page before stylesheets have loaded will cause a FOUC. Similar to how the devtools inspector causes a FOUC, any other Firefox extension that tries to access the page layout before stylesheets have loaded will also cause a FOUC. This is why the FOUC goes away when using a private browsing window without any extensions installed.
Next.js doesn’t wait for stylesheets to load before executing scripts. This causes a FOUC when one of those scripts tries to access the page layout before stylesheets have been loaded. This is the main issue here that should be addressed by Next.js maintainers. Notice how the “forced layout” console warning comes from one of my page scripts that tries to use
window.innerWidth
andwindow.innerHeight
:This might help: After hours of troubleshooting sudden FOUC in my next.js app (deployed at Vercel with styled-jsx, problems in production mode only) I discovered that I had styled-jsx installed as a separate package in my app. This created some conflict with next.js built-in styled-jsx. Deleting the package fixed it.