Best Ways to Load Google Fonts: Plugins vs Theme Enqueuing vs Hard-Coded in Header

[ad_1]

How do you all load Google Fonts into your themes? I prefer to do as much as possible without plugins and have traditionally enqueued the fonts using **wp\_enqueue\_style()** in the functions.php file.

However, I haven’t revisited this in a while and notice that Google Fonts now provides two additional link elements (using **rel=”preconnect”**) that I’m not utilizing.

My initial searches point to using the **add\_action( ‘wp\_head’ )** to essentially print these three Google Fonts elements into the head element of the site, but I was always under the impression that using **wp\_enqueue\_style()** was the way to go.

What do you think? Is printing to head the way to go or is there a way to incorporate the preconnect elements while enqueuing as usual? Or can you convince me using a font managing plugin is the way to go? Thanks in advance.

[ad_2]
1 Comment
  1. Following out of curiosity. Right now I download the font and use the font-face rule and import them from my theme, but interested if there’s a better solution.

 

This site will teach you how to build a WordPress website for beginners. We will cover everything from installing WordPress to adding pages, posts, and images to your site. You will learn how to customize your site with themes and plugins, as well as how to market your site online.

Buy WordPress Transfer