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:
- Maintain your high score on Pagespeed Insights by leveraging your browser cache, and
- 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:
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 v5.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.
Installing the Plugin from the WordPress Repository

I assume you’ve done this before. I’ll just leave it here for full disclosure:
- From within your WordPress admin-area, go to Plugins > Add new.
- Enter ‘OMGF’ (without the quotes) in the search bar.
- 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:
- Go to Settings > Optimize Webfonts.
- 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.

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 CDN, Subsets Forcing and setting Fallback Font Stacks. Click here to read more about OMGF Pro and get a 20% 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.
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!

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

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.
Wow Man, a great write up, I have been using COAS 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 🙂
Thanks, James! I’m looking forward to any feedback you might have! And thanks for using OMGF!
OMGF great plugin for wordprss.
Thanks Daan ! my website page speed 20% increase.
Thanks for the compliment, Mohini!
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?
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!
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?
No, it doesn’t modify the theme file. It enqueues the stylesheet (wp_enqueue_style()) in your theme’s header (wp_head()).
Happy you like the plugin!
OMGF just *halved* the Time To First Byte of my ecommerce. Simply AMAZING!!!
Hi Vans!
Thanks for letting me know. Enjoy OMGF 😀
Hi,
thanks for this great plugin.
Is there a way to store Icons, for example https://fonts.googleapis.com/icon?family=Material+Icons, also local?
Best regards,
Ole
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!
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.
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: https://themify.me/docs/enqueue-scripts, 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!
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.
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. fonts.google.com). So you should be able to use this option without any problems.
Is the fonts.css generated by OMGF 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.
Hi Daan,
How can I check if my stylesheet with the fonts is still active? I have the idea that it has been deleted.
Cheers,
Stefan
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.
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. ”
and
“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.
Hi Jonathan, I’m sorry I never replied to your comment. Hope you still get to read it.
The first issue can be resolved by setting the Font-Display option to ‘Swap’. The 2nd issue needs to be resolved on your server. Except if it lists external resources, there’s nothing you can do about that.
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,
Richie
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.
Hi Daan,
Thanks for the prompt reply. I fully understand the need to focus on the performance of the core program. One day, perhaps. 🙂
Just wanted to let you know that I added an auto detect feature in OMGF a while ago. 🙂
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?
cheers,
Samuel
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!
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.
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.
Hi Chritra,
Thanks your for your feedback. I’ll write up a post soon in which I’ll explain how to find the fonts your theme is using.
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)
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. 🙂
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..
Best,
Florian
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!
Perfect. If I understand you correctly, I just leave the CDN box blank then?
Yep!
Thanks Sir, you rock!
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 ?
Hi Chris,
Yes, hosting fonts locally means being able to control the caching duration. In .htaccess you should specify the duration (minimum 1 month) per filetype. This list you’ll find basically all of them: https://gist.github.com/solancer/a51cf728a119a16f4c6ce494864a2d47
Hey Daan, Thanks for the plugin. If I still see this in the header : type=”text/css” rel=”stylesheet” href=”//fonts.googleapis.com/css?family=Raleway:400,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?
Thanks!
Hi Phet,
Yes, that means that OMGF wasn’t able to remove the fonts. Have you tried the latest version, though? I’ve improved the Remove-method in the past few releases.
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
Martina
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.
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!
David
Hi David,
Have you tried the latest version? I’ve made a lot of improvements in the font downloading methods since v2.1.1.
Hi Daan, thanks for the great plugin!
In working with the plugin, 2 questions came to mind.
How to remove an installed font-weight or how to add a font to an installed set of fonts? Just re-download and re-generate stylesheet?
The other issue addresses the use of a subset of the complete alphabet (&text=). Can this be accomplished with your plugin?
Thanks in advance.
Kind regards.
Hi Wyb,
You can just remove the font you don’t need anymore and re-generate the stylesheet.
As for your second question, more and more people are asking me about this. I’ll see what I can do about this. At this point it cannot be done with the plugin.
Is there a way to ensure the text remains visible during font load as suggested by Google on this page: https://web.dev/font-display/
Hi Peter,
Have you tried setting the ‘font-display’ option in OMGF? Try setting it to ‘fallback’.
Let me know how it goes!
It was on font-display: swap;fallback’. But Google pagespeed insight is still suggesting that I “ensure the text remains visible during font load”.
Though I noticed that the body of my website now displays text during font load.
What is left is hero section which I made with Slider Revolution.
Website is https://www.idokopaul.com
Hi Daan,
the plugin sounds great. Just one question: Can it be uninstalled once everything has been done?
Thanks,
Bettina
Hi Bettina,
No, it can’t. But that’s on purpose. 🙂
A good plugin doesn’t make permanent changes to other files (which would be required in what you’re asking). This is to make sure that everything will keep working as intended after e.g. updates or other changes.
Saludos desde Venezuela amigo, muy agradecido por su trabajo, y felicitaciones por su gran calidad.
Una consulta a ver si me puede apoyar. Ese listado que donde aparece la etiqueta “Preload”, y luego al lado de cada casilla la opcion “remove”. ¿Para que sirve? Hay que hacer algo adicional alli para optimizar el manejo de las fuentes?
Muchas gracias de antemano.
Hi Nelson,
I ran your comment through Google Translate (I don’t speak Spanish) and updated the post to give more insights into what the ‘Preload’ function does. 🙂
Enjoy!
The download button seems to stuck at 0% without responding.
Please advise
I answered your question in the Support Forum. Let’s keep communication through one channel. It’s more efficient. 🙂
Hi Daan,
I installed the plugin and activated it. However when I click on auto detect I get this error message:
Table wpkc_omgf_fonts does not exist and is necessary for OMGF to function properly. Try manually de-activating and activating the plugin via the WordPress plugins screen.
Any idea how I can fix this? I tried deactivating the plugin and reactivating it, but it did not work.
Thanks
Hi Jaco,
Did you also post your question on the Support Forum or did another Jaco ask the same question there? Anyway, I’ll copy the answer here: 🙂
1. Go to your wp_options table in your database (the prefix wp might be different),
2. Remove the line called omgf_db_version,
3. Reload any page in the admin-area.
Is the error gone?
Hi. I have no idea where the support forum is so sorry to post this here.
I deleted the row omgf_db_version & reloaded the admin page
and still received
“Table wpkc_omgf_fonts does not exist and is necessary for OMGF to function properly.”
Any ideas?
Hi Jeff,
No problem. could you check your database if the table actually exists?
Very nice plugin, all seems to be working, but a little confused….
Site is using Questrial 400, 600 weight, but when I did auto scan it only found 400. I created the CSS and fonts are no longer loaded from Google, but there is no 600 weight in the CSS or local font, but it’s still displaying buttons using 600 weight. I have cleared cache, but if I use font inspector it says Weight 600, Style Normal for buttons and Weight Normal, Style Normal for body text.
Any ideas??
Hi Darren,
Short and simple answer: every browser is capable of faking font styles, if the regular style (400) is available. 🙂
So, since you have 400 present, the browser mimics a thicker font, even an italic style. But, for example, you won’t see a difference between weight 600 and 900.
Okay makes sense, so basically I don’t need to worry about it? I wish your plugin localised Typekit fonts, they are slower than Google fonts!
Yes, basically you don’t need to worry about it. More complex fonts, will look distorted if the browser tries to mimic another style, but simpler fonts basically look the same!
Thanks for your plugin. I’ve installed it and tried to use it on my website https://www.qallwdall.com (which is in Arabic language and using Arabic fonts).
I think the plugin wasn’t enable to detect the font(s), as it shows an empty cell. Also when I click download it gives me “NaN%”. Can you please help me with that? This is the font I’m using in my website “Droid Arabic Kufi” – 400
Thanks in advance
Hi Mohammed,
Which theme are you using?
this is the font css
https://fonts.googleapis.com/earlyaccess/droidarabickufi.css
I’m using publisher theme
super pumped I found this! Thank you Daan! My cookie plugin issued a warning that Google fonts might not be GDPR compliant thus sending me down a rabbit hole trying to figure out if I should leave them in, if they are compliant or not. AAAANDD… nope, nothing definitive, grey area. This solution is elegant, easy and worked perfectly. I use Divi theme, all I made sure to do was to uncheck ‘Use Google Fonts’ before checking the setting in the OMGF plugin. I still have a pesky dns prefetch to google.com that I want to remove also so working on that now.
Hi John, thanks for the great compliments!
Also using Autoptimize by any chance? This adds a dns-prefetch, when the Google Fonts option is set to ‘Leave as is’. Set it to ‘Remove Google Fonts’ and you should be all good!
Btw, if you need help with configuring OMGF with Divi to fully make it work, hire me. I’ll make it work.
Hi Daan,
Thanks for the great plugin! It’s very helpful for me. One question I have is how can I move loading the fonts to after the page has been loaded? Please assume I can tweak any code including php/css/js/etc.
Thanks,
Roi
Hi Roi,
In
host-webfonts-local/includes/frontend/class-functions.phpon line 130, change this line:wp_enqueue_style(self::OMGF_STYLE_HANDLE, OMGF_FONTS_URL . '/' . OMGF_FILENAME, array(), (OMGF_REMOVE_VERSION ? null : OMGF_STATIC_VERSION));To this:
wp_enqueue_script(self::OMGF_STYLE_HANDLE, OMGF_FONTS_URL . '/' . OMGF_FILENAME, array(), (OMGF_REMOVE_VERSION ? null : OMGF_STATIC_VERSION), true);That should do it!
I’ll add this as an option in a future release. I mean, more people might be looking for this!
Note: Actually prohibited by Google to cache the fonts CSS more than 24 hours:
https://developers.google.com/terms/#e_prohibitions_on_content
Hi Kendell,
Good find! You had me worried there for a second. 😉
OMGF doesn’t cache their CSS, it generates its own. The cache header of their fonts equals 1 year, so I guess we’re good there, too 🙂
Hi Daan,
What an awesome plugin, thank you developing it! 🙂
A quick question: When I clicked “auto-detect”, it detected more than 100 fonts. Obviously, I’m not using that many. Do you know what caused this or is it something I should worry about?
Also, when I compare the fonts on staging-site with OMGF enabled, and my live site, everything else looks as should, but typing that’s on style: bold/strong is a “bit off” with the OMGF enabled site. Have you run into this before?
TIA!
This article is not usefull anymore, beacause the plugin has change completly. Most of the featured that you show in this article is no longer exist. Please remove it from the internet. Thanks.
HA! Remove it from the internet!? You’re kidding right? The article needs updating, I agree. I haven’t had the time. Running a one-man-show here, not a big corporation. Some patience is in order. Thanks.
Hi,
You’re right. The plugin has changed since I wrote this and this post requires updating. I’ll get to it ASAP.
thanks for the work your doing am happy
Hi Daan
When clicking on “Refer to the manual” in your article above, and arriving at the Manual page, a user gets the following:
“Last updated on
Last updated date for article not found.
Try appending ?refresh_docs to URL to refresh contents.
Article ID could not be found.”
Hi David,
Thanks for notifying me! The URL is fixed.