Custom font produce dragging behavior (FOUT, FOIT)
See original GitHub issueIs this a bug report?
Yes
Environment
node -v
: v6.10.3npm -v
: 3.10.10yarn --version
(if you use Yarn): 0.27.5npm ls react-scripts
(if you haven’t ejected): 1.0.11
Then, specify:
- Operating system: OSX 10.12.6
- Browser and version:
- Chrome Version 60.0.3112.101
- Safari Version 10.1.2
Steps to Reproduce
git clone git@github.com:tsmirnov/create-react-app-fout-example.git
yarn start
Try to update page several times. You will see FOUT.
Expected Behavior
I expect page load without dragging (FOUT, FOIT)
Actual Behavior
First page load behave like this:
Reproducible Demo
https://github.com/tsmirnov/create-react-app-fout-example
I added custom font like @gaearon proposed on stackoverflow. However, I get FOUT.
This is happening, because fonts are loaded asyncronusly. Synchronous font loading must solve the problem. I couldn’t find anywhere how to do it properly without eject. I can work on PR, to solve that issue. What do you think?
Issue Analytics
- State:
- Created 6 years ago
- Comments:9 (5 by maintainers)
Top Results From Across the Web
FOUT, FOIT, FOFT - CSS-Tricks
When using a custom font via @font-face, browsers used to display a ... This makes the behavior like FOUT – speeding up readable...
Read more >Font loading strategies: FOIT and FOUT
FOIT and FOUT are font loading strategies used by browsers to load custom fonts. FOIT shows an invisible text while FOUT uses a...
Read more >Controlling Font Performance with font-display
If the font face is not yet loaded when this period starts, it's marked as a failed load, causing normal font fallback.
Read more >FOIT vs FOUT: a comparison on web font loading - Rock Content
In this content, we will deal with the FOIT vs. FOUT comparison, addressing each of their details and the impact on custom font...
Read more >Scaling Fonts Automatically | Apple Developer Documentation
If you use a custom font in your app and want to let the user control the text size, you must create a...
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
So, I’ve investigated that issue. The reason we get FOIT is that browser loads fonts asyncronusly. User see the page first, browser loads font and then renders the page again.
The most reasonable solution is to use fontfaceobserver and defer rendering before fonts are loaded:
I don’t think we can fix that inside react-scripts. I think, we should just add this recommendation to documentation on how to use custom fonts. Should I make a PR for README.md?
No worries!