優化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

相關文章
相關標籤/搜索