解决fonts.googleapis.com造成国内wordpress博客打开缓慢的方法

2014年06月8日

原创内容,转载请注明出处:https://www.myzhenai.com.cn/post/1825.html https://www.myzhenai.com/thread-16250-1-1.html
Google不能使用的解决方法请参考: https://www.myzhenai.com.cn/post/820.html https://www.myzhenai.com.cn/post/694.html https://www.myzhenai.com.cn/post/692.html https://www.myzhenai.com/thread-15207-1-1.html https://www.myzhenai.com.cn/post/677.html
很多wordpress架设的博客在浏览的时候总是会在浏览器状态栏那里看到停顿很久的一行内容“fonts.googleapis.com”如果您是一个站长,刚好您的博客浏览的时候卡在这里的时候,可以使用这个方法来解决.fonts.googleapis.com是Google字体服务器域名,因为国内已经封锁了Google服务,所以很多Google服务打不开了. 要么你让你的浏览用户上梯子,要么替换他们的host文件,要么就是你从源代码中做改变.
我们需要修改的是 wp-includes/script-loader.php 在这个文件中找到 $open_sans_font_url = “//fonts.googleapis.com/css?family=Open+Sans:300italic,400italic,600italic,300,400,600&subset=$subsets”; 这一行.
如果你不想按照我以下方法修改的话,你可以将fonts.googleapis.com替换成74.125.128.95 我发现这样也是可以打得开Google的.

$url = 'https://fonts.googleapis.com'; //赋值给一个变量,这个变量的内容就是fonts.googleapis.com
if(fopen($url)) //判断这个地址是不是能够打开,进入判断语句
{ //如果地址可以正常打开,那么script-loader.php文件里的这一行我们不需要替换.
$open_sans_font_url = "//fonts.googleapis.com/css?family=Open+Sans:300italic,400italic,600italic,300,400,600&subset=$subsets"; 
}else
{ //如果不能够正常打开,自动替换成fonts.useso.com服务器的.
$open_sans_font_url = "//fonts.useso.com/css?family=Open+Sans:300italic,400italic,600italic,300,400,600&subset=$subsets";
}

 
将以上代码(先将我的注释删除掉.)复制粘贴到 // Hotlink Open Sans, for now 这一行下方.保存后上传覆盖原来的文件即可.现在你可以发现浏览你的博客速度快很多了.
网上有个方法是简单的将fonts.googleapis.com替换成fonts.useso.com的,因为我是希望Google能够正常使用的时候继续使用Google原始的字体服务器,而不是360的CDN节点缓存.所以我才做了一个判断.希望对大家有所帮助。

解决 fonts.googleapis.com 造成 国内 wordpress 博客 打开 缓慢 方法

解决fonts.googleapis.com造成国内wordpress博客打开缓慢的方法


解决 fonts.googleapis.com 造成 国内 wordpress 博客 打开 缓慢 方法

解决fonts.googleapis.com造成国内wordpress博客打开缓慢的方法


解决 fonts.googleapis.com 造成 国内 wordpress 博客 打开 缓慢 方法

解决fonts.googleapis.com造成国内wordpress博客打开缓慢的方法


sicnature ---------------------------------------------------------------------
Your current IP address is: 3.236.226.100
Your IP address location: 美国弗吉尼亚阿什本
Your IP address country and region: 美国 美国
Your current browser is:
Your current system is:
Original content, please indicate the source:
同福客栈论坛 | 蟒蛇科普海南乡情论坛 | JiaYu Blog
sicnature ---------------------------------------------------------------------
Welcome to reprint. Please indicate the source https://myzhenai.com/post/1825.html

1 评论

  • 源码窝 2014年06月23日在7:14 上午

    直接把字体换了很方便的一个方法

发表回复

您的电子邮箱地址不会被公开。 必填项已用*标注