Answer the question
In order to leave comments, you need to log in
How to download fonts correctly?
Good afternoon, there was a question about the correct preloading of the font, please help me figure it out
Google Page Speed writes that the fonts specified in css interfere with rendering because of this type, the indicators fall if the fonts are connected like this:
@font-face {
font-family: Lora;
font-display: swap;
src: local("Lora Italic"), local("Lora-Italic"),
url(/fonts/lora/Lora-Italic.woff2) format("woff2"),
url(/fonts/lora/Lora-Italic.woff) format("woff");
font-weight: 400;
font-style: italic;
}
<link rel="preload" href="/fonts/lora/Lora-Italic.woff2" as="font" type="font/woff2" crossorigin>
Answer the question
In order to leave comments, you need to log in
I think that for "correctness" one should be guided by the fact that you need to load only those fonts that are required and avoid FOS (flash of a regular font) - load the font before the block in which it is used and load synchronously.
And so, at your discretion and taking into account the structure / architecture of the page / application:
, @font-face{}, by direct url, from localstorage, in the form of base64.
Along the way, directly in the html code - 100% guarantees loading exactly where it is written and exactly at the time of the call. But you need to take into account the size of such pieces and the fact that such code will look scary. But 1-2 fonts can be uploaded...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question