My question comes from trying to optimize for lighthouse test's preloading key assets.
I've placed the fonts flagged by lighthouse report in Chrome browser into a link in my head file.
[header.php]
<link rel=”preload” href=”/wp-content/themes/mytheme/assets/font/Roboto/Roboto-Regular.ttf” as=”font” crossorigin=”anonymous”>
Do I still need to include it in my style.css file and declare the font-face?
[style.css]
@font-face {
font-family: "Roboto";
src: url("/wp-content/themes/mytheme/assets/font/Roboto/Roboto-Regular.ttf") format("truetype"); }
I'm asking because despite adding the preload link in my header, Lighthouse report still shows that my file is not preloading.
Thanks for your help all.