Archived topic
Add font-display: swap
22 replies · Started by Kristjan on August 25, 2019
Hi!
I added this filter:
add_filter( 'generate_google_font_display', function() {
return 'swap';
} );
to my functions.php file in a child theme, but unfortunately PageSpeed Insights still doesn't recognize it. What could I have done wrong?
I test on the entry: https://samochody-szwajcaria.pl/chrysler-grand-voyager-68/
Hi there,
the 2 x fonts are the GP Icon fonts, which can't be swapped as there icons and theres no fallback for them.
Instead go to Customizer > General and change the Icon Type to SVG.
Ok, thank you so much!
You're welcome!
Hello,
I have added the code
add_filter( 'generate_google_font_display', function() {
return 'swap';
} );
on the child theme
and I still get the problem in pagespeed
…fonts/generatepress.woff2. ("web"). 10 ms
…v36/4UaGrENHs….woff2(fonts.gstatic.com). 0 ms
…v18/KFOmCnqEu….woff2(fonts.gstatic.com). 0 ms
…v36/4UaGrENHs….woff2(fonts.gstatic.com). 0 ms
…v36/4UabrENHs….woff2(fonts.gstatic.com). 10 ms
Hi there,
please raise a new topic where you can share a link to your site so we can take a look.
Hi Tom,
the filters above only work for google fonts used by generatepress right?.
Is there a easy way to set it for generatepress.woff2 and gp-premium.ttf as well?
thanks, Lars
Hi Lars,
GP fonts are icons, they can't be swapped with other fonts Unfortuanly.
I would recommend switch to SVG instead of using fonts for better performance at customizer > general.