D
D
Dmitry Cherednichenko2018-12-12 14:57:43
css
Dmitry Cherednichenko, 2018-12-12 14:57:43

What is the correct way to display all text before loading fonts?

Hello.
Google Pagespeed has this recommendation:
Set All Text to Show While Web Fonts are Loading
To allow the user to see text while the web fonts are not loaded, use the CSS font display feature.
The fonts are connected in the project like this:

@font-face {
  font-family: "Museo Sans";
  src: local('Museo Sans'), local('MuseoSans'), url("../fonts/museosans/regular.eot?#iefix") format("embedded-opentype"), url("../fonts/museosans/regular.woff2") format("woff2"), url("../fonts/museosans/regular.woff") format("woff"), url("../fonts/museosans/regular.ttf") format("truetype");
  font-display: swap;
}

That is, in fact, the recommendation is made, but Pagespeed still offers it. What am I doing wrong?

Answer the question

In order to leave comments, you need to log in

4 answer(s)
S
Soho, 2019-02-03
@focuspro

@font-face {
  font-display: swap;
  font-family: "Museo Sans";
  src: local('Museo Sans'), local('MuseoSans'), 
  url("../fonts/museosans/regular.eot?#iefix") format("embedded-opentype"), 
  url("../fonts/museosans/regular.woff2") format("woff2"), 
  url("../fonts/museosans/regular.woff") format("woff"),
  url("../fonts/museosans/regular.ttf") format("truetype");}

First, the loading rule is written, and then the font, and not vice versa

L
LobsterJoe, 2018-12-12
@LobsterJoe

I guess you should use fallback fonts , maybe that will solve the problem.

S
sozonovalexey, 2018-12-28
@sozonovalexey

Through trial and error, I found out that you need to specify the path to the font without../

L
lukoie, 2019-02-11
@lukoie

1 the font must be connected in the header, and not from the css
2 the font in the body is indicated in the type form
that is, you need to specify not only the font that you will use, but also the font that will be used before the desired one is loaded, and if the desired one cannot be loaded for some reason.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question