majodev / google-webfonts-helper

A Hassle-Free Way to Self-Host Google Fonts. Get eot, ttf, svg, woff and woff2 files + CSS snippets
https://gwfh.mranftl.com
MIT License
12.02k stars 420 forks source link

font-display support #91

Closed knuklus closed 1 year ago

knuklus commented 4 years ago

To get points on google PageSpeed Insights, you need to add the font-display: swap property. In order not to enter it manually.

alexlii1971 commented 4 years ago

it seems an Know-how, but how and where should I input please?

knuklus commented 4 years ago
@font-face {
  font-family: 'Montserrat';
  font-style: normal;
  font-weight: 100;
  font-display: swap;
  src: local('Montserrat Thin'), local('Montserrat-Thin'),
       url('../fonts/montserrat-v14-latin_cyrillic-ext-100.woff2') format('woff2'), 
       url('../fonts/montserrat-v14-latin_cyrillic-ext-100.woff') format('woff'); 
}
deenamo commented 4 years ago

Just to note, Google Fonts supports this natively with &display=swap query param: https://fonts.googleapis.com/css?family=Open+Sans:300,400,400i,600,700,700i&display=swap

This param is currently applied by default when getting an embed code from Google Fonts UI.

davidcalhoun commented 4 years ago

For more context, the font-display property helps with the Flash of Unstyled Text (FOUT) or Flash of Invisible Text (FOIT) on page load, and that's why it's recommended by PageSpeed Insights.

nextgenthemes commented 4 years ago

Hi guys, I created a download tool in PHP that works on the server and as a CLI script. It supports display=swap. See nextgenthemes.com/google-webfont-downloader/

majodev commented 1 year ago

Fixed within v1.1.0.