Pages render without styles for a brief second
See original GitHub issueBug 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:
// _app.tsx
import '../assets/styles/global.scss';
const MyApp = () => { ... }
export default MyApp;
// global.scss
@mixin system-font() {
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Oxygen",
"Ubuntu", "Cantarell", "Fira Sans", "Droid Sans", "Helvetica Neue",
sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
body {
@include system-font();
background: white;
color: $text-color;
line-height:1.5;
}
Then all my pages and components follow this pattern:
// my-page.tsx
import './my-page.scss'
const MyPage = () => { ... }
export default MyPage;
// my-component.tsx
import './my-component.scss'
const MyComponent = () => { ... }
export default MyComponent;
Expected behavior
I expect pages to render with styles without such flickering.
System information
- OS: macOS Catalina 10.15.5
- Browser: Firefox 78.0.2
- Version of Next.js: 9.4.4
- Version of Node.js: 12.18.1
Issue Analytics
- State:
- Created 3 years ago
- Reactions:8
- Comments:47 (5 by maintainers)
Top Results From Across the Web
FOUC: Initial page loaded without any styles - Stack Overflow
But the issue is, styles are not getting pre-applied on page load. Because of which FOUC happens for all the initial page render....
Read more >Next.js and Styled-Components: style loading issue
js app but can't get the styles to load properly? This is because the server-side rendering does not fetch the styles before rendering...
Read more >Server-side rendered styled-components with Nextjs
Server-side rendering the styles. To enable server side rendering of the styles, we will need to do two things: hook into the renderPage...
Read more >Advanced Usage - styled-components
This example renders our above themed Button and a second one that uses a second ThemeProvider to invert the background and foreground colors....
Read more >Render Blocking CSS - web.dev
What would happen if we try to render a typical page without blocking rendering on CSS? Summary #. By default, CSS is treated...
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
Closing as there was no full reproduction provided.
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.