Font-Display check should consider icon fonts
See original GitHub issueFeature request summary
A special check to not recommend font-display: swap
for icon fonts.
What is the motivation or use case for changing this?
There seems to be no clear recommendation on what is actually best practice for icon fonts, and even if there is, it’s not swap
but actually block
. So I would suggest either adding a special rule to to detect icon fonts or maybe whitelist the most common ones so they don’t trigger the lighthouse warning when swap
is not set.
Relevant links:
- https://github.com/FortAwesome/Font-Awesome/issues/14387
- https://www.zachleat.com/web/font-display-icon-fonts/
- https://stackoverflow.com/questions/49461308/correct-font-display-value-for-icon-fonts
How is this beneficial to Lighthouse?
Currently the Lighthouse recommendation is not actual the best practice and might cause people blindly following it to get unintended behaviour.
Issue Analytics
- State:
- Created 4 years ago
- Reactions:6
- Comments:10 (1 by maintainers)
Top Results From Across the Web
font-display is Incompatible with Icon Fonts—zachleat.com
The main point that I think hasn't really been communicated enough is that icon fonts exist in a place that would seem to...
Read more >Correct font-display value for icon fonts - Stack Overflow
It would be the perfect thing for something like icon fonts where the icon (probably) has no meaning unless the custom font loads....
Read more >Best practices for fonts - web.dev
If ensuring text is displayed in a web font is a top priority: Use font-display: block but make sure to deliver the font...
Read more >Seriously, Don't Use Icon Fonts - Cloud Four
Most assistive devices will read aloud text inserted via CSS, and many of the Unicode characters icon fonts depend on are no exception....
Read more >font-display | CSS-Tricks
The font-display property defines how font files are loaded and displayed by the browser. It is applied to the @font-face rule which defines ......
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
Thanks for filing @Stanzilla!
The Lighthouse audit is not looking for
swap
it’s looking for any valid font-display value that’s not the default. If you follow icon font best practices and useblock
, the audit will pass.The Learn More docs are misleading on this point, so we’ll update those 👍
@PatOnTheBack A digression, is there any tool to test and compare the performance of svg and font icons?