优化Google字体 全面加速WordPress

从5月27号起,因为某些缘由,Google服务在大陆的崩溃影响了数百万的站长,由于不少wordpress主题都在使用Google的在线字体方案-google fonts包括新版的WordPress 后台也有加载谷歌的JS。Google服务一不稳定,就影响独立博客的字体加载,使wordpress站点加载速度很慢。php

为此,特整理部分修改方案。html

1、将原Google地址替换为360的CDN(推荐)

利用360网站卫士提供的前端公共库CDN服务(http://libs.useso.com/)替换原有Wordpress的Google JS便可.
前端

[步骤]:api

1.打开Wordpress文件: 根/wp-includes/script-loader.phpdom

2.搜索关键字 fonts.googleapis.com编辑器

3.替换fonts.googleapis.com为fonts.useso.comide

4.保存文件,便可。wordpress

2、去除google字体

1.用notepad++打开主题的 functions.php文件,在末尾添加如下代码:字体

//禁用Open Sans
class Disable_Google_Fonts {
public function __construct() {
add_filter( ‘gettext_with_context’, array( $this, ‘disable_open_sans’ ), 888, 4 );
}
public function disable_open_sans( $translations, $text, $context, $domain ) {
if ( ‘Open Sans font: on or off’ == $context && ‘on’ == $text ) {
$translations = ‘off’;
}
return $translations;
}
}
$disable_google_fonts = new Disable_Google_Fonts;

2.保存,上传覆盖到主题目录,便可.(可以使用其余编辑器但要注意编码格式)网站

3、使用插件(未经实验,不推荐)

可以使用Auto Remove Google’s URL插件来替换Google的地址.



原创于青互联博客http://www.qing.es/2014/06/150.html

相关文章
相关标签/搜索