google-webfonts-helper icon indicating copy to clipboard operation
google-webfonts-helper copied to clipboard

font-display support

Open knuklus opened this issue 4 years ago • 5 comments

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

knuklus avatar Dec 14 '19 07:12 knuklus

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

alexlii1971 avatar Dec 14 '19 08:12 alexlii1971

@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'); 
}

knuklus avatar Dec 14 '19 09:12 knuklus

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.

deenamo avatar Jan 03 '20 19:01 deenamo

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.

davidcalhoun avatar Jan 04 '20 19:01 davidcalhoun

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/

nextgenthemes avatar Jun 28 '20 20:06 nextgenthemes