不推薦使用代碼禁用,很多都無效
解決辦法一:
在functions.php裡面添加如下代碼:
function hc_cdn_callback($buffer) {
return str_replace(‘googleapis.com’, ‘useso.com’, $buffer);
}
function hc_buffer_start() {
ob_start(“hc_cdn_callback”);
}
function izt_buffer_end() {
ob_end_flush();
}
add_action(‘init’, ‘hc_buffer_start’);
add_action(‘shutdown’, ‘hc_buffer_end’);
解決辦法二:
就是把把調用的谷歌的文件鏈接換成國內的鏈接。
註:暫時沒有找到合適的國內相關服務
解決辦法三:
把含有谷歌鏈接的代碼注釋掉,這個道理大家應該明白。注釋方法如下例子(在代碼前面加//就行了):
//wp_register_style(‘underthesea-pacifico’,“$protocol://fonts.googleapis.com/css?family=Pacifico”);
相關插件:Disable Google Fonts
通過wordpress後台安裝 ‘Disable Google Fonts’ 這個插件,這是最簡單的解決辦法,網上大多都是用的這個,不過我測試了一下,沒有效果,沒起效果的接着往下看!
注意:Disable Google Fonts長時間未更新,不建議使用
相關插件:Disable and Remove Google Fonts
簡介:
Improve frontend performance by disabling Google Fonts loaded by themes and plugins.
針對很多主題和插件載入的google字體有效。
測試情況:
安裝前,網站前台“查看源代碼”,使用Ctrl+F 搜索 fonts.googleapis.com 看看
安裝後,再看:
沒了。有效
高級分析
通過審查元素找到,拖慢後台加載速度的內容:
比如:
1.https://ajax.googleapis.com/ajax/libs/prototype/1.7.1.0/prototype.js
2.http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.21/themes/smoothness/jquery-ui.css
參考閱讀: