Google Fonts are sometimes heavy-weight and slow to load especially in some regions e.g. mainland China. The following PHP Function allows you to disable loading Google Fonts in your WordPress.
Edit the functions.php template of your child theme of the WordPress, then add the following lines of PHP Code.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | <?php add_filter( 'gettext_with_context', 'helloacm_disable_google_fonts', 888, 4); function helloacm_disable_google_fonts($translations, $text, $context, $domain) { $google_fonts_contexts = array( 'Open Sans font: on or off', 'Lato font: on or off', 'Source Sans Pro font: on or off', 'Bitter font: on or off' ); if (($text == 'on') && (in_array($context, $google_fonts_contexts))) { $translations = 'off'; } return $translations; } |
<?php add_filter( 'gettext_with_context', 'helloacm_disable_google_fonts', 888, 4); function helloacm_disable_google_fonts($translations, $text, $context, $domain) { $google_fonts_contexts = array( 'Open Sans font: on or off', 'Lato font: on or off', 'Source Sans Pro font: on or off', 'Bitter font: on or off' ); if (($text == 'on') && (in_array($context, $google_fonts_contexts))) { $translations = 'off'; } return $translations; }
That is it! You wordpress site will thus disable/remove loading the Google fonts, and you will see the page load speed improved at no time!
–EOF (The Ultimate Computing & Technology Blog) —
GD Star Rating
loading...
220 wordsloading...
Last Post: Teaching Kids Programming - Using Hash Set to Find Out Almost Same Strings
Next Post: Teaching Kids Programming - Three Consecutive Odds