How to correctly import fonts
Hey, if I have some
@font-face
declarations inside of a css file and import the css file in the html, I understand that this shouldn’t cause a problem because the assets wouldn’t load sequentially since they’re being imported through the html, thus not blocking the page render if it takes too long, but should I be importing fonts using a different method? Perhaps a link
tag if that exists for this? If so, how do i still get the benefits of @font-face
?
Thanks in advance6 Replies
If you're using custom fonts, @font-face gives you more control, and it’s fine to include it in a CSS file. For web fonts like Google Fonts, use the <link> tag for simplicity and faster setup. You can also combine both methods—preload the font with <link> and define it with @font-face to optimize loading times.
I like this article that explains three parts regarding performance best practice for fonts.
https://web.dev/articles/font-best-practices
web.dev
Best practices for fonts | Articles | web.dev
Learn about how to optimize web fonts for Core Web Vitals.
Joy of Code
Best Practices When Using Fonts
Everything I know about best practices when using fonts on the web.
Another resource
and remember: self-host your fonts
or use a google fonts alternative
Thanks for the input everyone, I’ll get to reading the articles