Next adds unnecessary CSS when using css-in-js solutions in dev mode
See original GitHub issueBug report
Describe the bug
When using something like styled-components, next now adds
<style data-next-hide-fouc="true">body{display:none}</style>
to the head
To Reproduce
View the source code of sites generated by the styled-components example.
Expected behavior
Don’t add any css when not required
Additional context
Has been added with 9.2.0’s new css feature, only happens in dev mode. The location of the buggy code: https://github.com/zeit/next.js/blob/2fe743581471279497b53ed692ff77c01be73e93/packages/next/pages/_document.tsx#L397-L419
Issue Analytics
- State:
- Created 4 years ago
- Comments:21 (4 by maintainers)
Top Results From Across the Web
Why We're Breaking Up with CSS-in-JS
So it recalculates the style rules. Then React renders the next component, and then that component discovers a new rule and it happens...
Read more >andreipfeiffer/css-in-js: A thorough analysis of all the ...
A thorough analysis of all the current CSS-in-JS solutions with SSR & TypeScript support ... We're using Next.js as a SSR framework for...
Read more >Basic Features: Built-in CSS Support
Next.js supports including CSS files as Global CSS or CSS Modules, using `styled-jsx` for CSS-in-JS, or any other CSS-in-JS solution! Learn more here....
Read more >The best styling options for Next.js
Built by Vercel, the founder of Next.js, Styled-JSX allows developers to write CSS in their JavaScript code. There is no setup necessary, and...
Read more >Comparing Styling Methods In Next.js
With Next.js, one of the things you need to know is how to integrate different CSS ... Changes to the index page after...
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 FreeTop 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
Top GitHub Comments
Hi @Timer.
We have a lot of white screens in dev because of this “feature” … Thanks to:
<style data-next-hide-fouc="true">body{display:none}</style>
If you make some features that brake the flow with such painful behaviour, maybe you can also add a flag to have the possibility to switch it off?
We’ve disabled client side JS so the page loads faster, but now it stays blank in dev mode. Is there a way to disable this?