Skip to main content
Host Google Fonts Locally

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 was like:
I was like: “I can’t. It’s too much.”

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 CAOS for Webfonts

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

CAOS for Webfonts
CAOS for Webfonts’ Banner. Isn’t she a beaut!?

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.

Installing the Plugin from the WordPress Repository

Installing CAOS from the WordPress Repository.
Installing CAOS from the WordPress 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 ‘CAOS’ (without the quotes) in the search bar.
  3. Choose the pink one and click ‘Install now’. Once it’s done, click ‘Activate’.

Configure CAOS for Webfonts

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 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:

If you don’t know it already, figure out the name of the font your blog is using. I usually do this by clicking my right mouse button on any line of text and choosing ‘Inspect element’ to open the browser’s Developer Tools. Need help? A quick Google search handed me this tutorial written by a really happy looking couple.

Although they don’t get cool points for using anything CAOS related, the tutorial is actually helpful.

How to Configure CAOS for Webfonts
How to Configure CAOS for Webfonts
  1. Go to Settings > Optimize Webfonts.
  2. Enter your font’s name in the search bar — to add more, wait till the previous search finished, empty the search box and enter the next font’s name.  Add as many different fonts as you like!
  3. Trim the list to include only the fonts your theme actually uses. I usually remove all the ‘italic’ ones, because any modern browser can fake italic fonts.
  4. Click ‘Download Fonts’ and wait for the command to complete. Depending on the size of your list and the speed of your server, this might take a minute. The download counter underneath the button will give you a hint of its current status.
  5. Click ‘Generate stylesheet’.
  6. Done!

See how easy that was? No 12-step program here! Your fonts have been downloaded and saved on your server, the stylesheet has been generated and added to your theme’s header.

Removing externally hosted Fonts

Now the only thing left to do is remove any mention of externally hosted Google Fonts from your Blog.

I use an integrated option in Autoptimize for this, because I’m already using that plugin for minification of my CSS and JS and I suggest you do too — because it’s lightweight and awesome. But if you (are lame and) don’t (want to) use Autoptimize, there’s plenty of other ways to achieve this. Either manually or through plugins.

Some themes offer an integrated toggle for this in the Theme’s options. If your theme doesn’t, there are many other ways to achieve this.

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.

Daan van den Bergh

Magento 2 Back-end Developer with a passion for trainlifting, airplane-gliding, hunting trees and creating fake hobbies.

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

  1. Wow Man, a great write up, I have been using the COAS for Analytics on my older blogs, just found out the name change and installed on my new blog too.

    Now I am going to install the webfonts plugin and will definitely share my feedback here.

    Thumbs up 🙂

  2. It seems like every time I type in a font name and generate a stylesheet, it overwrites the prior one I’d created. Also doesn’t seem to work if I type in multiple font names, whether separated by spaces, commas, or otherwise. How does this work for multiple fonts?

    1. Yeah, I see it works a little counter intuitive at this point. I’ll definitely take this up in a future update.

      At this point, when you search, the found fonts are entered in the list. When you remove your search query and look for another font, the newly found fonts are added to the same list.

      I should really pay more attentiont to User Experience in my next release. Thanks for letting me know, Sam!

  3. First. Great plugin. Many thanks and hurrays!
    Now a question.
    So I’m done so far as I got this message
    “Stylesheet was successfully generated and added to your theme’s header.0”
    Looks a bit buggy with that 0? anyway…

    What did actually happen?
    Did it modify the theme’s template file?

    1. Yes, of course. Al you need to do is:
      – Download the fonts.
      – Download the stylesheet (your link).
      – Save it on your server and change the URL (inside the src: url(”)) to the full URL on your server.
      – Done!

  4. Hi Daan,

    Thanks for the great plugin! My only question is, you say to turn the fonts off in the theme or remove any mention of them.

    However, I use Themify and there is a toggle in the theme settings, but then it turns off the fonts altogether. How can I stop calling for downloaded fonts, but still use them in my theme, if that’s what I’m supposed to do? Cheers.

    1. Hi David,

      Good question!

      The goal we want to achieve is that the CSS remains unchanged, e.g.

      body {
          font-family: 'Roboto';

      This should remain! We just want to use our own stylesheet where the url’s of the stylesheet are defined, instead of the one hosted on Google’s servers.

      What I think I understand from your message, is that when you switch the toggle in Themify, this removes the mention of the font in the CSS as well. Correct?

      I did a little Googling and found this page:, so I think this should do the trick:

      After creating the child theme (as mentioned in the article), add the following code snippet to the child theme’s functions.php:

      add_action('wp_enqueue_scripts', 'daan_remove_scripts', 20);
      function daan_remove_scripts(){
          wp_dequeue_style( 'google-fonts' );

      Let me know how that goes!

  5. How do I block elementor page builder, astra theme and wordpress if needed, from making google fonts requests? I use autoptimize. I tried to set it to block google fonts in the “extra” tab, but then it doesnt load the locally stored fonts instead.

    1. That can’t be right. Autoptimize only blocks the fonts loaded from Google’s servers as it recognizes Google Fonts by the url (e.g. So you should be able to use this option without any problems.

      Is the fonts.css generated by CAOS for Webfonts loaded? If not, then the problem is probably your theme.

      In that case you should create a child theme which loads the stylesheet and disables astra’s google fonts.

      If you don’t know how to do this, please contact me using the contact form and I’ll try and help you out.

  6. Hi Daan,

    How can I check if my stylesheet with the fonts is still active? I have the idea that it has been deleted.


    1. This is why every browser has an ‘Inspector’! 🙂

      Open up your browser’s inspector tools (usually by pressing F12) and go to the tab ‘Network’ (in Chrome and Firefox). Reload the page and check if a file called fonts.css is loaded — make sure to disable any combine/minify plugins and clear your caches before doing this! If it is loaded, you know it’s there. If it’s not, try to re-download and re-generate the stylesheet. If you’re using WP Super Cache (or an equivalent) it might be this is deleting the stylesheet whenever you clean the cache. In that case you should also change the path where CAOS saves the stylesheet and fonts.

  7. Hi there,

    Great post, just looking for some advice – when I do the Pagespeed test, the results advise:

    “Ensure text remains visible during webfont load
    Leverage the font-display CSS feature to ensure text is user-visible while webfonts are loading. ”


    “Serve static assets with an efficient cache policy
    8 resources found
    A long cache lifetime can speed up repeat visits to your page.”

    How would you recommend to resolve the above – I use WPRocket and stackpath CDN.

    Thank you.

  8. Hi Daan,

    Firstly, many thanks for writing CAOS for Analytics and CAOS for Webfonts. 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 CAOS for Webfonts 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 CAOS for Webfonts, 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. 🙂

  9. 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, CAOS for Webfonts does not support uploading custom fonts. But I’ll keep it on my list, as a feature to be added. Thanks for the suggestion!

  10. 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.

Leave a Reply

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.