Why the Gutenberg Editor Can Load Slowly
The WordPress Gutenberg Editor is the default block editor since WordPress 5.0. Some users report slow loading times, partly because the editor loads a Google Fonts stylesheet (CSS), which can be affected by network conditions.
Solution: Disable Google Fonts Loading
You can prevent the Gutenberg editor from loading Google Fonts by adding a small code snippet to your active theme's functions.php file, potentially improving backend editor responsiveness.
Steps to Implement
- Log into your WordPress admin dashboard.
- Navigate to Appearance → Theme File Editor.
- In the file list on the right, select Theme Functions (functions.php).
- Add the provided code snippet to the end of the file.
- Click Update File to save your changes.
Code Implementation
Add the following PHP code to your theme's functions.php:
/**
* Disable Google Fonts in the Gutenberg Editor
*
* @param string $translation Translated text.
* @param string $text Text to translate.
* @param string $context Text context.
* @param string $domain Text domain.
* @return string Modified translation or 'off' to disable font.
*/
function disable_gutenberg_google_fonts( $translation, $text, $context, $domain ) {
// Intercept the specific Google Font load attempt in Gutenberg
if ( $context !== 'Google Font Name and Variants' || $text !== 'Noto Serif:400,400i,700,700i' ) {
return $translation;
}
// Return 'off' to prevent the font from loading
return 'off';
}
add_filter( 'gettext_with_context', 'disable_gutenberg_google_fonts', 10, 4 );
Explanation and Important Notes
- How It Works: This code uses the WordPress
gettext_with_contextfilter. When the Gutenberg editor tries to load the specific "Noto Serif" Google Font, the function returns 'off' instead, blocking the request. - Limitations: This method targets a hardcoded font load in earlier Gutenberg versions. The loading mechanism may change with core WordPress updates.
- Alternative Method (Recommended): If the above code doesn't work, or you want to completely remove Google Fonts from the editor, use this more robust approach that dequeues the style:
/** * Remove Google Fonts styles from the Gutenberg Editor */ function remove_gutenberg_google_fonts() { wp_dequeue_style( 'wp-editor-font' ); // Note: The style handle may change in future versions. } add_action( 'enqueue_block_editor_assets', 'remove_gutenberg_google_fonts', 100 ); - Critical Advice: Always use a child theme or a code snippets plugin to add custom code. Direct edits to a parent theme's
functions.phpwill be lost when the theme updates. - Testing: After adding the code, clear your site and browser cache, then reload the post editor to check if loading speed improves.
Conclusion
Disabling unnecessary remote resources like Google Fonts is an effective way to optimize WordPress admin performance. The methods provided here address a specific optimization point for the Gutenberg editor. For newer WordPress versions, check official update logs and consider using performance optimization plugins for comprehensive resource management.