pixelgrade / customify

Intuitive Website Styling integrated into WordPress' Customizer
GNU General Public License v2.0
28 stars 5 forks source link

Make sure fonts use font-display: swap property #221

Closed vladolaru closed 4 years ago

vladolaru commented 4 years ago

Related to this: https://wordpress.org/support/topic/swap-font/#post-12961283

Google Fonts have an optional parameter: https://web.dev/font-display/?utm_source=lighthouse&utm_medium=unknown#google-fonts

This is not a CSS property per se, but a @font-face descriptor. So it needs to reside inside the @font-face definition, not in a regular CSS rule.

vladolaru commented 4 years ago

Resources:

vladolaru commented 4 years ago

It seems that Web Font Loader doesn't support adding this parameter in a nice way (https://github.com/typekit/webfontloader/issues/409). A workaround is to modify the script: https://heiko-frenzel.de/fix-web-font-loader-pagespeed-insights-15782/

But if we give up on Web Font Loader in the frontend, like proposed here https://github.com/pixelgrade/customify/issues/218, we are in the clear. Although we would still need a solution for the Customizer.

vladolaru commented 4 years ago

Fixed this through the use of the new Google Fonts CSS API v2