Loading Google Fonts from Google's servers (fonts.googleapis.com) raises GDPR concerns because visitors' IP addresses are transmitted to Google. Self-hosting the fonts on your own server solves this issue and can also improve performance.
Method 1: Manual Self-Hosting
Step 1: Download the Fonts
Use Google Webfonts Helper to download the font files you need. Select the styles and character sets you require.
Step 2: Upload to Your Server
Upload the font files to your theme directory, e.g., /wp-content/themes/your-theme/fonts/.
Step 3: Add CSS @font-face Rules
@font-face {
font-family: 'Open Sans';
font-style: normal;
font-weight: 400;
font-display: swap;
src: url('./fonts/open-sans-v40-latin-regular.woff2') format('woff2');
}
@font-face {
font-family: 'Open Sans';
font-style: normal;
font-weight: 700;
font-display: swap;
src: url('./fonts/open-sans-v40-latin-700.woff2') format('woff2');
}
Step 4: Dequeue Google Fonts
Remove the Google Fonts link from the HTML head:
add_action('wp_enqueue_scripts', function() {
wp_dequeue_style('google-fonts');
wp_deregister_style('google-fonts');
}, 100);
Method 2: Using a Plugin
The plugin OMGF (Optimize My Google Fonts) automates the entire process. It downloads Google Fonts, generates @font-face CSS, and removes the external Google Fonts references.
Verify with InspectWP
After self-hosting your fonts, run a new InspectWP scan. The GDPR section should no longer flag Google Fonts as loading from an external Google server.