Page 1 of 1

How to show an alternate font during web font loading periode?

Posted: Sun Sep 08, 2019 1:23 pm
by Markus
I use a google web font configured via Google font manager in my website.

Now I notice that the loading speed of the website, measures with some online SEO test tools, is classified as too slow because of the web font. The SEO tools attest me a time of more than 3 seconds on mobile devices until the content is completely displayed.

As a remedy it is recommended to use the CSS option "font-display", so that the content is already visible in a standard font during the loading process of the web font.

In my research I found the following code where font-display is used.

Code: Select all

@font-face {
  font-family: "Open Sans Regular";
  font-weight: 400;
  font-style: normal;
  src: url("fonts/OpenSans-Regular-BasicLatin.woff2") format("woff2");
  font-display: swap;
}
Can I also use this technique when using the Google font manager and if so, in what form do I have to implement it in my page?

I think the setting

Code: Select all

  font-display: optional;
will block the loading process the least.

https://css-tricks.com/font-display-masses/

Thank you in advance.
Markus

Re: How to show an alternate font during web font loading periode?

Posted: Sun Sep 08, 2019 1:36 pm
by Pablo
The font-face code is generated by Google, the application has no control over this.

Re: How to show an alternate font during web font loading periode?

Posted: Sun Sep 08, 2019 2:02 pm
by Markus
Oh, how stupid, yes you're right. It's actually a CSS file that gets the page from Google.
Now that I'm looking at the source code, it's clear.

Code: Select all

<link href="css/font-awesome.min.css" rel="stylesheet"><link href="https://fonts.googleapis.com/css?family=Lato:400,700,700,400" rel="stylesheet">
Image

Thanks Pablo