解決WordPress加載的google字體-網(wǎng)站打開(kāi)過(guò)慢的問(wèn)題

最近wordpress用戶反饋打開(kāi)刷新網(wǎng)站包括后臺(tái)訪問(wèn),都非常緩慢,用chrome觀察,發(fā)現(xiàn)網(wǎng)站在打開(kāi)fonts.googleapis這個(gè)項(xiàng)目花費(fèi)了20多秒,查下下fonts.googleapis這個(gè)項(xiàng)目是wordpress加載google字體的,而最近google全面被墻,估計(jì)就是導(dǎo)致眾多wordpress打開(kāi)緩慢的原因。而wordpress大概從wp-3.8開(kāi)始會(huì)自動(dòng)加載Open Sans字體,并引用Google上面的CSS樣式,造成了網(wǎng)站后臺(tái)也是打開(kāi)緩慢,令人發(fā)指。
fonts.googleapis解決方案一:
在主題中的functions.php文件末尾加上一下代碼之一即可。此方法僅在前臺(tái)有效,在后臺(tái)界面無(wú)效,因?yàn)閮H修改主題代碼。

1. 代碼一
// 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(‘a(chǎn)dmin_enqueue_scripts’, ‘remove_wp_open_sans’);
endif;
2. 代碼二
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’ );
fonts.googleapis解決方案二:插件過(guò)濾
此方法在前臺(tái)和后臺(tái)均有效。
1. 插件一
插件:Remove Open Sans font Link from WP core
簡(jiǎn)介:移除WP核心的谷歌字體鏈接.
2. 插件二
插件:Disable Google Fonts


 

本站使用的全部代碼如下:

//禁止WordPress后臺(tái)加載谷歌字體
function coolwp_remove_open_sans_from_wp_core() {
wp_deregister_style( 'open-sans' );
wp_register_style( 'open-sans', false );
wp_enqueue_style('open-sans','');
}
add_action( 'init', 'coolwp_remove_open_sans_from_wp_core' );
//禁止WordPress后臺(tái)加載谷歌字體

// 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(‘a(chǎn)dmin_enqueue_scripts’, ‘remove_wp_open_sans’);
endif;
//去掉加載谷歌字體



更多閱讀:

wordpress后臺(tái)登陸緩慢,原因是谷歌Open Sans字體無(wú)法加載

完美解決wordpress鏈接google字體慢的問(wèn)題

禁用谷歌字體加快wordpress網(wǎng)頁(yè)打開(kāi)速度!

禁止WordPress后臺(tái)加載谷歌字體

Google服務(wù)被“封”,服務(wù)器移到美國(guó)了,影響到使用谷歌字體的wordpress站長(zhǎng)們了,本文為解決辦法。

 
  • 本文由 米粒在線 發(fā)表于 2014年6月18日20:50:55
  • 轉(zhuǎn)載請(qǐng)務(wù)必保留本文鏈接:http://m.bjmhhq.com/24639.html
  • 谷歌
  • 網(wǎng)頁(yè)跳轉(zhuǎn)
  • 分享
  • 計(jì)算機(jī)
  • wordpress
  • 網(wǎng)頁(yè)字體
  • 網(wǎng)站建設(shè)
網(wǎng)站建設(shè)

寶塔面板設(shè)置Docker加速站提示錯(cuò)誤:全局配置文件有誤,請(qǐng)檢查Expecting value:line 1 column 1(char 0)解決方法

寶塔? docker? 修改加速 報(bào)錯(cuò):寶塔 設(shè)置失敗!讀取配置文件失敗:Expecting value: line 1 column 1 (char 0)解決辦法: 打開(kāi)文件:/etc/d...
百科知道

華碩路由器的ddns用不了, 還有哪個(gè)可以用,備選替代選擇

尊敬的華碩用戶: 為配合網(wǎng)絡(luò)安全法規(guī)及政策的要求,進(jìn)一步提升服務(wù)安全性與質(zhì)量,華碩將對(duì)ASUS DDNS服務(wù)進(jìn)行調(diào)整。當(dāng)前的ASUS DDNS服務(wù)將停止。我們?yōu)槟峁┝寺酚善鲀?nèi)嵌的其他第三方DDNS服...

發(fā)表評(píng)論

匿名網(wǎng)友
:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:
確定

拖動(dòng)滑塊以完成驗(yàn)證