Skip to content

What is the best option for loading fonts locally? #378

Answered by vinkla
silverliiv asked this question in Q&A
Discussion options

You must be logged in to vote

I'm glad to hear that you have discovered WordPlate and are enjoying using it 😃

This is how I load fonts in WordPress, which is not only great for performance but was also recommended to me by an SEO company. Placing the fonts in resources/static directory will prompt Vite.js to automatically move them into the theme assets directory when you run the command npm run build.

<head>
    <link rel="preload" href="<?= get_theme_file_uri('assets/fonts/inter-var-roman.woff2') ?>" as="font" type="font/woff2" crossorigin="anonymous">
    <link rel="preload" href="<?= get_theme_file_uri('assets/fonts/inter-var-italic.woff2') ?>" as="font" type="font/woff2" crossorigin="anonymous">

    <style>

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by vinkla
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #376 on June 06, 2023 17:12.