I'm getting the diagnostic on PageSpeed Insights
Ensure text remains visible during webfont load
Leverage the font-display CSS feature to ensure text is user-visible while webfonts are loading. Learn more.
URL
Potential Savings
…v1/aWB4m0aac….woff2(fonts.gstatic.com) 10 ms
…v21/nuFvD-vYS….woff2(fonts.gstatic.com) 10 ms
…v13/6xK3dSBYK….woff2(fonts.gstatic.com) 10 ms
And I'm trying to correct it by changing
<link rel="stylesheet" href="https://fonts.googleapis.com" />
to
<link rel="stylesheet" href="https://fonts.googleapis.com/display=swap" />
But this actually throws a console error
I know that PageSpeed Insights recommends to add font-display: swap
to @fontface
, but I don't know what @fontface
is.
I'm using Bootstrap and Gatsby
I know there's also gatsby-plugin-web-font-loader
. Is there a way to use this to avoid this diagnostic?
These are all the times font-family shows up in my program. I'm using scss
so most of them are variables
I only specify a font once in my program, and I think bootstrap chooses the font the rest of the time
blockquote > p {
font-family: 'Montserrat', sans-serif;
}
Update, I'm using this plugin now
{
resolve: `gatsby-plugin-google-fonts`,
options: {
fonts: [
`Montserrat`,
`Helvetica Neue`,
`Helvetica`,
`Arial`
],
display: 'swap'
}
},