Solutions for WP blog slow due to Google Fonts issue 3


Weeks ago, I upgraded my blog to WordPress 3.8. After that, I found that if I dont use GoAgent to break the GFW, it took me about 1 minute to show the home page.

After did some more check, I confirmed that its all because WordPress 3.8, and its latest version v3.8.1 are using Google Fonts, and its host (http://fonts.googleapis.com) is blocked by GFW. People inside the GFW are sucked by it.

The fact that WP is using Google Fonts in its default themes bugs me and guys inside GFW a lot.

Here are my solutions for this issue.

1. Install WordPress plugin

Login to your WordPress dashboard, and try search a plugin with keywords: “Disable Google Fonts”.

This plugin will help you to disabled the Google Fonts. However this plugin does not work on my theme: Twenty fourteen.

2. Modify source code manually

Locate & open “Theme Functions” source file: (functions.php), and add codes listed below to it:

a. Remove Google Fonts – Open Sans from WordPress Twenty Twelve theme

Copy and paste this code below into your functions.php.

//dispable google fonts open sans
function mytheme_dequeue_fonts(){
wp_dequeue_style( 'twentytwelve-fonts' );
}
add_action( 'wp_enqueue_scripts', 'mytheme_dequeue_fonts', 11 );

b. Remove Google Fonts – Source Sans Pro from WordPress Twenty Thirteen theme

Copy and paste this code below into your functions.php.

 //dispable google fonts Source Sans Pro
function mytheme_dequeue_fonts(){
wp_dequeue_style( 'twentythirteen-fonts' );
}
add_action( 'wp_enqueue_scripts', 'mytheme_dequeue_fonts', 11 );

c. Remove Google Fonts – Source Sans Pro from WordPress Twenty Fourteen theme

Simply comment out or delete the code in function twentyfourteen_font_url like below.

 function twentyfourteen_font_url() {
$font_url = '';
/*
* marked by jacky to disable Google Fonts and speed up your blog
if ( 'off' !== _x( 'on', 'Lato font: on or off', 'twentyfourteen' ) ) {
$font_url = add_query_arg( 'family', urlencode( 'Lato:300,400,700,900,300italic,400italic,700italic' ), "//fonts.googleapis.com/css" );
}
*/

return $font_url;
}

This works for me. Hope it works for you too, if not, leave me a word.

July 20, 2014 update:

This code will work for most of the themes, and all you need to do is add the follow code to the bottom of functions.php for your theme.

add_filter( 'gettext_with_context', 'wpdx_disable_open_sans', 888, 4 );
function wpdx_disable_open_sans( $translations, $text, $context, $domain ) {
  if ( 'Open Sans font: on or off' == $context && 'on' == $text ) {
    $translations = 'off';
  }
  return $translations;
}

 

 


Leave a comment

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

3 thoughts on “Solutions for WP blog slow due to Google Fonts issue

  • jual beli hp murah

    Whats up are using WordPress for your site platform?

    I’m new to the blog world but I’m trying to get
    started and create my own. Do you require any html
    coding expertise to make your own blog? Any help would be greatly appreciated!