woocommerce / storefront

Official theme for WooCommerce
https://wordpress.org/themes/storefront/
974 stars 470 forks source link

add font swap to google font css api #2080

Closed dowands closed 1 year ago

dowands commented 1 year ago

Add font swap to google font css display:swap to resolve "Ensure text remains visible" problem on web.dev

imanish003 commented 1 year ago

Hey @dowands, Thank you for taking the time to create this PR; we appreciate your contribution 🙏🏻

I had an internal discussion with the team regarding this. A store might prefer to display the content as soon as possible and replace the font when downloaded (font-display: swap). Still, other stores might prefer to block rendering until the font has completely downloaded font-display: auto/block. Therefore we don't want to hard-code swap as font-display value.

Also, FYI, In future, we plan to remove Google Fonts because Google Fonts cause a GPDR issue for EU websites. You can find more info about it in issue #2077.

One alternative way to change font-display value could be to unregister Google Fonts with the methods proposed in #2077 & then register the fonts directly with a CSS file, so you can add the font-display property as you want.

I will close this PR for now, but we can continue our discussion in the comments. Thanks again for your contribution 🙂