解决WordPress后台加载字体慢的方法

2014年6月11日 / 龙哥随笔 / 没有评论 / 1,897次

最近很多人说,WordPress后台加载字体很慢,原因是加载了google的字体,而Google会出现经常打不开或者访问速度过慢的情况,所以会拖延站点的打开速度。观察发现script-loader.php(wp-3.9)的580行代码进行加载。
那么我们怎么解决呢?
在主题中的functions.php文件末尾加上
代码1

1
2
3
4
5
6
7
8
9
10
11
// Remove Open Sans that WP adds from frontend
if (!function_exists('remove_wp_open_sans')) :
    function remove_wp_open_sans() {
        wp_deregister_style( 'open-sans' );
        wp_register_style( 'open-sans', false );
    }
    add_action('wp_enqueue_scripts', 'remove_wp_open_sans');
?
    // Uncomment below to remove from admin
    // add_action('admin_enqueue_scripts', 'remove_wp_open_sans');
endif;

代码2

1
2
3
4
5
6
function remove_open_sans() {    
    wp_deregister_style( 'open-sans' );    
    wp_register_style( 'open-sans', false );    
    wp_enqueue_style('open-sans','');    
}    
add_action( 'init', 'remove_open_sans' );

插件过滤移除WP核心的谷歌字体链接.地址:http://wordpress.org/plugins/remove-open-sans-font-from-wp-core/


提交评论