最近下载的wordpress3.9版本,安装之后特别慢,最后发现是Google Fonts导致的,真让人蛋疼.
Google Fonts导致WordPress 速度问题之原因
WordPress 自3.8+版本后加入了Google Fonts(别问我Google Fonts是什么了),然后捏,因为近期敏感周期(35号),天朝发威,谷歌的一系列网站被彻底墙,包括Google Fonts 所在的googleapis.com 。所以,如果是在登陆状态下打开你的WordPress 站点,会非常慢,因为压根儿加载不了这个字体文件。如果是非登陆状态且你的主题不是老外的主题,一般来说都是正常的。

解决方法
出来问题就要解决,在天朝,既然你不得不忍受之,那么就换个思路变通一下。下面的解决方法,思路一是禁止加载该Google Fonts,二是替换加载源。下面说明之:

方法一:【插件】禁止WordPress 后台加载Google Fonts

安装启用 Disable Google Fonts 或者 Remove Open Sans font Link from WP core 其中之一即可。没啥好说的。

方法二:【代码】直接在functions.php 文件添加代码

网络上有不少代码,下面可以参考下,具体有没有效果没有确认:

add_filter('gettext_with_context', 'disable_open_sans', 888, 4 );
      function disable_open_sans( $translations, $text, $context, $domain ){
             if ( 'Open Sans font: on or off' == $context && 'on' == $text ) {
             $translations = 'off';}return $translations;} 
      function dw_remove_open_sans() {      
            wp_deregister_style( 'open-sans' );          
            wp_register_style( 'open-sans', false );         
            wp_enqueue_style('open-sans','');      } 
            add_action( 'init', 'dw_remove_open_sans' );

方法三:【代码】替换open sans 字体的加载源

打开wordpress代码中的文件wp-includes/script-loader.php文件,搜索:fonts.googleapis.com 找到这行代码:

$open_sans_font_url = "//fonts.googleapis.com/css?family1=Open+Sans:300italic,400italic,600italic,300,400,600&subset=$subsets";

把fonts.googleapis.com替换为fonts.useso.com。
转载请注明转自:运达's blog 原文地址:http://www.yunda51.com/1337.html