Site logo

Archived topic

Leverage the font-display CSS feature For Google Fonts?

8 replies · Started by Rudy on April 24, 2019

Viewing posts 1–9 of 9

Hello, I'm trying to optimize my page speed and was wondering if there is any way to use the font-display css feature for the google fonts set in generatepress customizer? (I use google fonts) for headings.

Hi there,

the font-display property needs to be added to the @font-face CSS so i don't think there is currently a way of injecting that into the Customizer selected fonts. I will get Tom to take a look.

Out of curiosity what is your intention with the font-display?

On this subject could you consider adding font-display: swap; to your generatepress font css. I've adding it manually but it will be overwritten on a theme update. Thanks!

Yes I know. If you can tell me how to add the font-display:swap property after the font is already loaded I would like the info. I can't find a way to make it work in a child theme.

Hi there,

you would include the font-display property within your @font-face CSS rules for the locally hosted font.

Hi:
I added a code given by you guys and tom to my CSS snippets- no change on google pagespeed error.

People here say add to “ header” tag —?? Manually: Can this CSS code be added to snippets? Every article has a different code on this topic. Here is the warning:

Google Warning
Leverage the font-display CSS feature to ensure text is user-visible while webfonts are loading.

URL
Potential Savings
…fonts/generatepress.woff2(cdn.thesoundadvocate.com)
30 ms
…fonts/fontello.woff(cdn.thesoundadvocate.com)
40 ms

What is the “ literal” code needed for Arial font and where and how is it put in. (Ive never manually added code to my website before).

Hi there,

you can remove the generatepress.woff2 font by changing Customizer > General > Icon Type to SVG.

The fontello font is coming from a plugin - it also is an icon font - there isn't much we can do about that. And as its an icon setting a fallback/swap option would be pointless aside of removing a google warning that wouldn't actually improve performance.

This archived topic is closed to new replies.