Forum Moderators: open
<head>
<meta charset="utf-8" />
<title>Web font example</title>
<link
rel="preload"
href="fonts/cicle_fina-webfont.woff2"
as="font"
type="font/woff2"
crossorigin />
<link
rel="preload"
href="fonts/zantroke-webfont.woff2"
as="font"
type="font/woff2"
crossorigin />
<link href="style.css" rel="stylesheet" />
</head> @font-face {
font-family: myFont; /* set name */
src: url(/fonts/cicle_fina-webfont.woff2); /* url of the font */
} p {
font-family: myFont; /* use font */
} You could avoid all that in the <head> by adding a few lines to your CSS
If the @font-face is in your CSS file it does not need to have a 'preload' because the CSS has the local URL and preloads it.
Fonts defined with @font-face rules or background images defined in CSS files aren't discovered until the browser downloads and parses those CSS files. Preloading these resources ensures they are fetched before the CSS files have downloaded.
Preloading these resources ensures they are fetched before the CSS files have downloaded.And ...? The only time this could make a visible difference is if the user is on an ultra-slow connection. Or the site itself has an absurdly slow server; we've all seen sites where the html obviously loaded up a moment before the styles. In the first case, that's exactly when it is least considerate to start with a massive preload. In the second case, preloading resources is the least of your problems.