How to Locally Host Google Fonts and Leverage Browser Caching

Google Fonts. Every WordPress blogger uses them. It’s an easy — if not the easiest — way to improve your blog’s looks. Pagespeed Insights. We’ve all heard of that too. And we all want to achieve the highest possible score. Both are brought to you by the same entity we’ve come to know, love — and hate: Google. Love, because they gave us these beautiful fonts. Hate, because as soon as we use them, it lowers our score on Pagespeed Insights!

Today I’m showing you how you can achieve the best of both worlds:

  1. Maintain your high score on Pagespeed Insights by leveraging your browser cache, and
  2. Keep using your Google Fonts by hosting them locally.

And I promise you, it couldn’t be easier.

Locally Hosting Google Fonts shouldn’t be so Difficult.

I know, the web is flooded with tutorials about the essentials of leveraging your browser cache by hosting Google fonts locally. But to be honest: they’re long and boring.

They all explain which files to download, how to upload them to your WordPress blog, how to create a stylesheet, how to add your Google Fonts to said stylesheet, how to enqueue the stylesheet into your WordPress blog, and how to — well, I don’t know. A lot!

When I recently redesigned my blog (well, not really. I used a theme) I lost all my optimizations and my score on Pagespeed Insights plummeted. In other words, I came back around to this tiresome job and I was like:

I’m a backend developer. I don’t want to spend my time creating a stylesheet — no offense. I’d rather spend two days automating a tiresome — booooring — process, than spending one minute exercising said process.

And so I did. You’re welcome.

Host Google Fonts Locally in WordPress using OMGF

This post contains outdated information. It is based on OMGF v3.x. The most recent version of OMGF is v4.x, which contains a bunch of changes in the interface and UX. Refer to the manual for instructions on how to use and configure OMGF and OMGF Pro.

POW! There it is! Because of my frustration and arrogance, you now have a powerful WordPress plugin at your disposal. And it’s called OMGF. Not CAOS. No. I guess weird abreviations are my brand now. Consider this his beautiful baby sister. Her name is OMGF.

Because of her, you don’t have to download anything. You don’t have to unpack anything. You don’t have to upload anything. And you don’t have to create anything — especially a frickin’ stylesheet. No offense.

All you have to do is install the plugin from the WordPress repository, select your fonts, and click a few buttons. Let’s do this.

Request my OMGF Expert Configuration service if you’re not sure what you’re doing and/or can’t get it to work. Read more

Installing the Plugin from the WordPress Repository

Search for OMGF in WordPress Plugins Repository

I assume you’ve done this before. I’ll just leave it here for full disclosure:

  1. From within your WordPress admin-area, go to Plugins > Add new.
  2. Enter ‘OMGF’ (without the quotes) in the search bar.
  3. Choose the pink one and click ‘Install now’. Once it’s done, click ‘Activate’.

How to Configure OMGF

Although the WordPress plugin works fairly straight forward. I thought it might be a good idea to give you a quick crash course. Pay attention.

In theory, you could use this plugin (and its Additional Fonts add on) to change your blog’s fonts to anything you like, but we will not be covering that in this tutorial as we’ll have to touch a stylesheet. And if you’ve been paying attention, you’d know that I don’t like stylesheets — no offense.

Most users will want to replace the fonts they’re already using with locally hosted ones. Here’s how you do this:

  1. Go to Settings > Optimize Webfonts.
  2. Scroll down the settings page and click Save & Optimize.

You should see a message at the top of the screen, saying Optimization completed successfully. If you’re seeing an error or warning message, please refer to the Troubleshooting section of OMGF’s documentation.

Once the optimization has completed successfully, scroll down the settings page and you’ll notice the Manage Optimized Fonts section has populated with (several) stylesheets, containing font families and font styles.

The optimize Google Fonts section of OMGF gives you an overview of all locally hosted Google Fonts in your WordPress configuration.
The Optimized Google Fonts section of OMGF v4 will give you an easily configurable overview of all locally hosted Google Fonts on your WordPress configuration.

All the fonts in the list are already downloaded to your server and OMGF will make sure they are served when visitors (or you) view your site.

To tweak your Google Fonts’ performance further, OMGF offers the option to unload unused Google Fonts and preload fonts used above the fold.

OMGF Pro offers several advanced ways to further Optimize your Google Fonts’ performance, including serving font files from your CND, Subsets Forcing and setting Fallback Font Stacks. Click here to read more about OMGF Pro and use the coupon code BIGFANOFYOURBLOG to get a 10% discount on your purchase!

See how easy that was? No 12-step program here!

Below are some more tips on how you can further optimize the performance of your Google Fonts.

  • The Wait is Over.

    Get the Newsletter you've always wanted, now!

    Sign up to receive monthly, Special Offers & Free Optimization Tips for WordPress.

    Privacy Policy

    No spam. I promise.

  • Unloading Italic Font Styles

    I’d strongly suggest unloading any Italic font styles as Modern browsers are perfectly capable of mimicking italics using the regular font styles of any font family.

    Instruct OMGF to do so, by simply clicking Unload Italics next to each Font Family’s name.

    Many theme developers simply request all available font styles when using Google Fonts. So in some situations, using this option can shrink down your stylesheet by 50% — and chop of 50 – 100KB of your page size as well!

    Using OMGF's Unload Italics option, I was able to remove 6 requests and increase Google Fonts performance!
    Using OMGF’s Unload Italics option, I was able to remove 6 requests and optimize Google Fonts! Chopped ~50KB of my pagesize!

    Preload Google Fonts used Above the Fold

    Cumulative Layout Shifting is often caused by Google Fonts.

    The browser loads your page and first renders its text in a default system font. Then it stumbles upon the stylesheet for Google Fonts and loads them. This causes the text to shift around.

    We don’t want that, do we?

    To further optimize your Google Fonts I’d recommend preloading all font styles used above the fold.

    Don’t Preload All Fonts!

    Don’t preload all your Google Fonts. This is not a better safe than sorry scenario.

    Preloading all your Google Fonts (even those below the fold) will slow down initial rendering time and decrease your score in Google PageSpeed Insights for Largest Contentful Paint (LCP).

    What’s Above the Fold, you ask? Well, anything above the green dotted line is!

    Why should I host Google Fonts locally?

    Locally hosting your Google Fonts gives a great increase in page load times, because your visitor’s browser doesn’t have to make a round-trip to Google’s servers to retrieve the files. It also gives you full control of the files’ expiry time, eliminating the Leverage Browser Caching notice on sites offering performance metrics, such as GTMetrix, Pagespeed Insights and Pingdom.

    78 thoughts on “How to Locally Host Google Fonts and Leverage Browser Caching”

    1. Hi Daan,

      Firstly, many thanks for writing CAOS and OMGF. It’s very generous of you to share your expertise like this.

      Being a beginner (I’ve just set-up my first blog) I really appreciate the guidance that you provide for installing your plugins. Which leads me to … is there any way for OMGF to detect what fonts the user has used? This stuff is all new to me and it took me a while to track down what font was in use – for anybody else using the OceanWP theme the default font is Open Sans. An addition for a future update perhaps?

      Thanks again,

      1. I’ve looked into this many times, Richie. Thanks for the suggestion, though. Till now I haven’t found a solid way to implement this without sacrificing performance, etc.

        If I ever find one, it would definitely be a great addition to OMGF, but for now, I’m afraid I prefer to keep this plugin nice and tidy. The way it is.

        1. Hi Daan,

          Thanks for the prompt reply. I fully understand the need to focus on the performance of the core program. One day, perhaps. 🙂

    2. Hi Daan,

      Thank you for this awesome plugin. It’s really a piece of cake to handle the fonts! Just one question. I use Droid Sans on my page and I can’t find it from within your plugin. Is there a way to manually upload the font and still use your plugin?


      1. Hi Samuel,

        Droid Sans is not available, since it is not hosted on Google Fonts, but on Monotype.

        Currently, OMGF does not support uploading custom fonts. But I’ll keep it on my list, as a feature to be added. Thanks for the suggestion!

    3. Hi Daan,
      First of all, thanks for the supplement and for the explanations, but I have a problem, when I save the source I tell to do it on my child theme, but when I go to my editor I do not see the source, I really do not know what I am doing wrong and I would so much be grateful for your help.

    4. Hi,

      I was recommended to use this plug in and installed but after installing, I could not figure out to set up. I try to download fonts but does not see. Also I could not find which google font is using in theme.

    5. Hard to read the content. The site seems to be having issue with the css. Is there any alternative for font in use (example: theme option by developer)

      1. Hi, thanks for notifying me! It was due to the width of the Giphy, which for some reason was hard-coded into the database with a set width of 800px. No idea why, but it’s fixed now. 🙂

    6. Hi Daan

      Very grateful for your plugin!

      Is there an option to add 2 URLS to the CDN option? Cloudflare has provided me with 2 options..


      1. Since CloudFlare handles your DNS, you don’t have to do anything. analytics.js will be requested via their CDN, since their CDN handles the request via their DNS.

        I hope that makes sense.

        Thank you for using OMGF!

    7. OMG! finally! after hours of searching on google, that ‘s exactly what I need!
      Will test this ASAP. Thanks for this perfect work.
      Just one quick question, is there anything to add specifically for these local fonts in htacess to ensure a long caching ?

    8. Hey Daan, Thanks for the plugin. If I still see this in the header : type=”text/css” rel=”stylesheet” href=”//,500,600,700,800%7CLato:300,400,700%7CRaleway”

      Does it mean it did not work? Shouldn’t the href be pointed to somewhere on my server?


    9. Hello Daan,
      I am totally new to WordPress and HTML or CSS but I with your plugins help I managed to cut of the Google Fonts my theme was using. The stylesheet was generated and I see the fonts.css is being loaded.
      I guess I did not get it fully yet but what do I have to do to actually use the new fonts I downloaded. I would be very thankful if you could point me to some help.
      Thanks a lot

      1. Hi Martina,

        Thanks for using OMGF!

        If you want to use OMGF to download other fonts, rather than the ones used by your theme, you’re going to need to modify the CSS stylesheet of your theme.

    10. Dear Daan, thank you for this great plugin. Unfortunately the plugin wouldn’t download the fonts to the folder (font name “IBM Plex Sans”) from Google Fonts. I already tried to set write permissions with FTP (777) etc., but it wouldn’t work. The plugin also only creates a css file with only the header data. I guess this is a permission issue? Is there anything else I need to do? Version is 2.1.1 with WordPress 5.3.
      Thank you!

    Leave a Comment

    Your email address will not be published. Required fields are marked *

    This site uses Akismet to reduce spam. Learn how your comment data is processed.