Preload Fonts in WordPress Without a Plugin

Preloading fonts in WordPress is one of the easiest ways to improve WordPress performance, especially your LCP (Largest Contentful Paint) and FCP (First Contentful Paint) scores. When you preload a font, the browser fetches it early, preventing layout shifts and slow text rendering.

This guide shows the exact steps to preload fonts in WordPress without using any plugin, including how to find your font URLs, how to add preload code safely, and how to verify it works.


πŸ§ͺ Testing Notes of Preload Fonts in WordPress

βœ” Tested on: WordPress 6.6+
βœ” Theme: Astra Pro
βœ” PHP Versions: 7.4 / 8.0 / 8.2
βœ” Verified on: PageSpeed Insights, Chrome DevTools, Cloudflare CDN
βœ” Browsers: Chrome (Desktop + Mobile)

You may also need this: GZIP Compression In wordpress Without Plugin


⭐ Why Preload Fonts in WordPress Matters

When fonts are not preloaded, your text may appear late or with a fallback font. This causes:

  • Flash of unstyled text (FOUT)
  • Layout shift
  • Delayed LCP
  • Poor PageSpeed scores

By preloading important .woff2 files, the browser gives them highest loading priority.


1. Identify Your Font File URL

Before you preload anything, you must know the exact font file URL.

How to find it:

  1. Open your website in Chrome.
  2. Press F12 (or right-click β†’ Inspect).
  3. Go to the Network tab.
  4. Filter by Fonts.
  5. Reload the page.
  6. Copy the URL of the .woff2 or .woff file.

Chrome DevTools β†’ Network β†’ Fonts β†’ showing the font file URL.

preload-fonts-in-wordpress-1

2. Preload Fonts in WordPress via <link rel="preload"> (Simple Method)

If your theme allows editing the header.php file, add the following inside the <head> tag:

<link rel="preload" href="https://yourwebsite.com/wp-content/uploads/fonts/Inter-Regular.woff2" as="font" type="font/woff2" crossorigin>

Important:

  • Use the full absolute URL
  • Keep crossorigin if the font is loaded across origins
  • Recommended only if you are comfortable editing theme files

header.php editor showing the preload tag inside <head>

preload-fonts-in-wordpress-2

Editing header.php is risky because updates can overwrite changes.
Instead, use the wp_head hook inside functions.php:

// Add font preload tags
function wplp_preload_fonts() {
    echo '<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>' . "\n";
    echo '<link rel="preload" href="https://yourwebsite.com/wp-content/uploads/fonts/Inter-Regular.woff2" as="font" type="font/woff2" crossorigin>' . "\n";
}
add_action( 'wp_head', 'wplp_preload_fonts', 1 );

Why this method is better:

βœ” Survives theme updates
βœ” Loads preload very early with priority 1
βœ” Easy to manage multiple fonts
βœ” Works with any theme or builder

functions.php editor showing the preload code.

preload-fonts-in-wordpress-3

4. Preloading Google Fonts (Optional)

If you are using Google Fonts (not self-hosted), use preconnect and optionally preload self-hosted woff2 versions:

function wplp_preload_google_fonts() {
    echo '<link rel="preconnect" href="https://fonts.googleapis.com">' . "\n";
    echo '<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>' . "\n";
}
add_action( 'wp_head','wplp_preload_google_fonts', 1 );

If you self-host Google Fonts, preload the .woff2 file the same way shown above.


5. How to Verify Preload is Working

A) Chrome DevTools

  1. Open DevTools β†’ Network
  2. Reload the page
  3. Filter by Fonts
  4. Your font should show Initiator: link-preload

Network panel showing preload in the Initiator column.

Preload Fonts in WordPress 4

B) PageSpeed Insights

Run your URL β†’ PageSpeed should show lower LCP and fewer β€œReduce render-blocking resources” warnings.

PageSpeed Insights improvement after preloading.

preload-fonts-in-wordpress-result

6. Preload Best Practices

  • Preload only critical fonts (usually the one used in the hero or body text).
  • Don’t preload large font files that are not immediately visible.
  • Always use .woff2 if available (smallest file size).
  • Combine preload with preconnect to reduce DNS and SSL handshake delays.

7. Common Mistakes to Avoid

❌ Preloading too many fonts
❌ Preloading fonts that are not used above the fold
❌ Wrong file URL β†’ results in 404
❌ Missing crossorigin when loading from a different domain
❌ Adding preload in the wrong place (should be at top of <head>)


βœ” Quick Copy-Paste Checklist

  • Identify your .woff2 URL
  • Add preconnect
  • Add preload tag (as="font")
  • Add crossorigin
  • Insert via functions.php (recommended)
  • Test using DevTools + PageSpeed

FAQ

1. Should I preload all my fonts?

No. Only preload fonts used above the fold. Preloading too many fonts can slow down your site.

2. Is crossorigin required?

Yes, if the font loads from another domain (including CDN or Google Fonts).

3. Which font format should I preload?

Always prefer .woff2 β€” it is the fastest and most compressed.

Leave a Comment

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

Scroll to Top