最近发现我的博客加载越来越慢,一直以为是因为我的博客主机放在国外,被最近的Wall影响到了,所以也就没怎么注意。今天用firefox打开的时候发现一直停在等待加载fonts.googleapis.com中。看来问题被发现了,是该解决了。
个人原创,转载请注明原文出处,并保留原文链接:
http://www.embbnux.com/2014/06/20/wordpress_disable_open_sans_lato_front/
搜索了一下,发现网页打开缓慢的原因是因为一直在加载goole的一个字体open sans,这个字体css在google的服务器上,最近google打不开众所周知,没想到影响到这里了,没办法只能不用这个字体了。我用的是twentytwelve的主题。
解决方法:
在你的主题文件加下找到function.php,在最后的位置添加下面的语句:
1
2
3
4
5
6
7
8
9
10
|
/*禁止google fonts*/
add_filter(
'gettext_with_context'
,
'disable_open_sans'
, 888, 4 );
function
disable_open_sans(
$translations
,
$text
,
$context
,
$domain
)
{
if
(
'Open Sans font: on or off'
==
$context
&&
'on'
==
$text
) {
$translations
=
'off'
;
}
return
$translations
;
}
|
然后就好了,真是坑爹!
如果用的是twentyfourteen主题的话,还有个lato字体也是谷歌的,也得禁止。
一样在function里面删除该字体:
1
2
3
4
5
6
7
8
9
|
// 删除 Lato 字体
function
qot_dequeue_fonts() {
wp_dequeue_style(
'twentyfourteen-lato'
);
}
add_action(
'wp_enqueue_scripts'
,
'qot_dequeue_fonts'
, 11 );
|
完事大吉了。