Skip to content

How to Self-Host Google Fonts in WordPress for FREE?

Key Takeaways

  • Nexter Extension 4.9.2 adds Self-Host Google Fonts under Nexter > Nexter Extension > Performance > Google Fonts, and the option is part of the free Nexter Extension plugin.
  • Self-Host Google Fonts saves stylesheet link tags from fonts.googleapis.com/css and css2 into wp-content/nxt_assets/localfonts/, then changes the page to use the local copy.
  • Display Swap sets display=swap on Google Fonts links, and in the test with Nexter Blocks 5.0.11 it keeps both font families in a link that lists two families.
  • Disable Google Font removes link tags for fonts.googleapis.com, fonts.google.com and fonts.gstatic.com, while Reset deletes saved files and requires clearing page cache before the files download again.
Table of Contents

Self-hosting serves Google Fonts that are added through fonts.googleapis.com/css link tags from your own server. Turn on Self-Host Google Fonts under Nexter > Nexter Extension > Performance > Google Fonts. The option is part of the free Nexter Extension plugin.

What It Does

When a page is viewed, the plugin looks for stylesheet link tags that point to fonts.googleapis.com/css (including css2). It saves that stylesheet and the font files it lists into wp-content/nxt_assets/localfonts/, then changes the link to your local copy.

Why It Matters

A page that uses Google Fonts the default way asks a Google server for the stylesheet and font files. With a local copy, those linked fonts come from your own domain, so the visitor’s browser does not need to request them from Google. This alone does not make a site compliant with any privacy law. Check your own pages and get advice for your case.

What You Get

  • Self-Host Google Fonts: serves matching linked Google Fonts from your server
  • Display Swap: asks the browser to show fallback text while a Google Font loads
  • Disable Google Font: removes Google Fonts link tags from the page
  • Clear Google Fonts: a Reset button that deletes the saved files

Benefits

  • No manual font downloads or @font-face code
  • The change happens in the page output, so your design settings stay as they are
  • If the Google stylesheet cannot be fetched, the original Google link stays in place

Capabilities

SettingWhat happens on the front end
Self-Host Google FontsMatching link tags point to a local stylesheet and local font files
Display Swapdisplay=swap is set on Google Fonts stylesheet links; with self-hosting on, the saved stylesheet contains font-display: swap
Disable Google FontLink tags for fonts.googleapis.com, fonts.google.com and fonts.gstatic.com are removed. Self-hosting and Display Swap do not run

How It Works

Nothing is downloaded when you save the setting. The files are fetched the first time a page that links to a Google Font is viewed, and later views reuse them. Each different font address gets its own saved stylesheet. If the stylesheet cannot be fetched, the plugin waits 15 minutes before it tries that address again.

In our test with Nexter Extension 4.9.2 and Nexter Blocks 5.0.11 on a local site, a theme-style font link and the font links printed by Nexter Blocks were all switched to local files, for logged-out and logged-in views. The saved font files were in TTF format.

How to Use It

  1. In your WordPress dashboard, go to Nexter > Nexter Extension > Performance.
  2. Turn on the Google Fonts card and click Configure.
Nexter Performance screen with the Google Fonts card turned on
  1. Turn on Self-Host Google Fonts. Add Display Swap if you want fallback text during loading. Leave Disable Google Font off.
  2. Click Save.
Google Fonts panel with the Self-Host Google Fonts setting highlighted and the Save button marked
  1. Clear any page cache, then open a page of your site.
  2. In your browser developer tools, open the Network tab, reload and filter for fonts.g to see whether anything still loads from Google.

Use Cases

  • A theme or plugin adds Google Fonts through link tags and you want them served from your domain
  • You moved to system or uploaded fonts and want Google Fonts link tags removed
  • You changed fonts and want to clear the old saved files

Limitations

  • In our test with Display Swap off, one link that listed two font families was saved with only the first one. With Display Swap on, both were saved. If a font goes missing, turn on Display Swap, save and clear the page cache.
  • Only link tags in the page output are rewritten. Fonts loaded through a CSS @import rule, by JavaScript or from inside another stylesheet or iframe are not matched.
  • Feeds, post previews, the Customizer preview and embeds are skipped by self-hosting. The WordPress admin, including the editor, is not rewritten.
  • A dns-prefetch hint for fonts.googleapis.com can remain in the page source with self-hosting on. It is a hint to look up the domain, not a font download.
  • The site must be able to reach Google to fetch the files, and must be able to write to wp-content.
  • Saved files can be a different format from the one your browser gets directly from Google, so compare page weight before and after if that matters to you.

Troubleshooting

One of your fonts is missing after self-hosting

Check whether Display Swap is off. In our test, a link with two font families lost the second one in that state. Turn Display Swap on, click Save and clear the page cache.

Fonts still load from Google

Check that the Google Fonts card and Self-Host Google Fonts are both on and Disable Google Font is off, then clear your page cache. If a request remains, find where it starts in the Network tab: an @import rule, a script or an embed is not rewritten. If the stylesheet could not be fetched, wait 15 minutes and view the page again. If the local stylesheet loads but a font file is missing, click Reset, clear the page cache and view the page again.

Fonts disappeared and a fallback font shows

Check whether Disable Google Font is on. It removes the link tags, so the browser falls back to another font. Turn it off, save and clear the cache.

Fonts break after you click Reset

Reset deletes the saved files. A cached page can still point to them. Clear your page cache and reload so the files are downloaded again.

Suggested Reading

Checked with Nexter Extension 4.9.2 (free).

Share your Thoughts

Still in Doubt? Let’s Assist You

Have Feedback or Questions?

Join our WordPress Community on Facebook!