<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>七牛加速在线字体 on 张戈博客</title><link>https://zhang.ge/tag/%E4%B8%83%E7%89%9B%E5%8A%A0%E9%80%9F%E5%9C%A8%E7%BA%BF%E5%AD%97%E4%BD%93/</link><description>Recent content in 七牛加速在线字体 on 张戈博客</description><generator>Hugo -- gohugo.io</generator><language>zh-cn</language><lastBuildDate>Fri, 12 Dec 2014 06:21:02 +0000</lastBuildDate><atom:link href="https://zhang.ge/tag/%E4%B8%83%E7%89%9B%E5%8A%A0%E9%80%9F%E5%9C%A8%E7%BA%BF%E5%AD%97%E4%BD%93/index.xml" rel="self" type="application/rss+xml"/><item><title>利用七牛云存储加速WordPress谷歌在线字体</title><link>https://zhang.ge/qiniu-cdn-google-fonts.html</link><pubDate>Thu, 22 May 2014 03:47:23 +0000</pubDate><guid>https://zhang.ge/qiniu-cdn-google-fonts.html</guid><description>&lt;img src="https://zhangge.net/img/uploads/2014/06/googlefonts1-300x82.png" alt="Featured image of post 利用七牛云存储加速WordPress谷歌在线字体" /&gt;&lt;p&gt;在 &lt;a class="link" href="https://zhang.ge/duoshuo-reset-issues-disable-google-fonts.html" title="禁用谷歌在线字体，提高加载速度。"&#10; &gt;禁用谷歌在线字体的方法&lt;/a&gt; 一文，收到了一位技术达人的留言：&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="https://zhangge.net/img/uploads/2014/06/googlefonts1.png" target="_blank" rel="noopener"&#10; &gt;&lt;img alt="googlefonts1" loading="lazy" sizes="(max-width: 767px) calc(100vw - 30px), (max-width: 1023px) 700px, (max-width: 1279px) 950px, 1232px" src="https://zhangge.net/img/uploads/2014/06/googlefonts1-300x82.png"&gt;&lt;/a&gt;&lt;/p&gt;&#10;&lt;h2 id="反向代理方案的启发"&gt;反向代理方案的启发&#10;&lt;/h2&gt;&lt;p&gt;前往他的博客学习了一番，发现他的方法很不错，既保留了 Open Sans，又不影响开启速度。不过，他是通过反向代理实现翻墙的，他也提到速度并不那么给力。&lt;/p&gt;&#10;&lt;p&gt;作为一个七牛的老用户，瞬间就想到了完全可以用七牛来实现这种苦逼的加速事情啊！说干就干！&lt;/p&gt;&#10;&lt;h2 id="用七牛实现加速"&gt;用七牛实现加速&#10;&lt;/h2&gt;&lt;p&gt;&lt;strong&gt;Ps：此方法已宣告失败，可以不用浪费时间继续往下看了，桑心啊。&lt;/strong&gt; 挑了一个空闲的七牛空间，将一键加速设置为谷歌 Open Sans 地址：&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="https://zhangge.net/img/uploads/2014/06/googlefonts2.png" target="_blank" rel="noopener"&#10; &gt;&lt;img alt="googlefonts2" loading="lazy" sizes="(max-width: 767px) calc(100vw - 30px), (max-width: 1023px) 700px, (max-width: 1279px) 950px, 1232px" src="https://zhangge.net/img/uploads/2014/06/googlefonts2-300x157.png"&gt;&lt;/a&gt; &lt;a class="link" href="https://zhangge.net/img/uploads/2014/06/googlefonts3.png" target="_blank" rel="noopener"&#10; &gt;&lt;img alt="googlefonts3" loading="lazy" sizes="(max-width: 767px) calc(100vw - 30px), (max-width: 1023px) 700px, (max-width: 1279px) 950px, 1232px" src="https://zhangge.net/img/uploads/2014/06/googlefonts3-300x205.png"&gt;&lt;/a&gt; &lt;strong&gt;然后&lt;/strong&gt;，参考 &lt;a class="link" href="http://www.sxb.pw/1598.html" title="解决 wordpress 调用 Google 在线字体加载速度变慢的问题"&#10; target="_blank" rel="noopener"&#10; &gt;sxbxjhwm&lt;/a&gt; 提供的资料，修改 WordPress 文件：&lt;/p&gt;&#10;&lt;h2 id="替换字体地址"&gt;替换字体地址&#10;&lt;/h2&gt;&lt;p&gt;①、编辑 wp-includes 下的 script-loader.php 和/js/tinymce/plugins/compat3x/css/dialog.css&lt;/p&gt;&#10;&lt;p&gt;搜索找到 fonts.googleapis.com，然后替换成你设置的七牛空间地址即可，如 marsgecdn.qiniudn.com&lt;/p&gt;&#10;&lt;p&gt;如下所示：&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="https://zhangge.net/img/uploads/2014/06/googlefonts5.png" target="_blank" rel="noopener"&#10; &gt;&lt;img alt="googlefonts5" loading="lazy" sizes="(max-width: 767px) calc(100vw - 30px), (max-width: 1023px) 700px, (max-width: 1279px) 950px, 1232px" src="https://zhangge.net/img/uploads/2014/06/googlefonts5-300x229.png"&gt;&lt;/a&gt;&lt;a class="link" href="https://zhangge.net/img/uploads/2014/06/googlefonts6.png" target="_blank" rel="noopener"&#10; &gt;&lt;img alt="googlefonts6" loading="lazy" sizes="(max-width: 767px) calc(100vw - 30px), (max-width: 1023px) 700px, (max-width: 1279px) 950px, 1232px" src="https://zhangge.net/img/uploads/2014/06/googlefonts6-300x185.png"&gt;&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;Ps：如果用的是 wp 的原生主题，一般还要修改主题中包含 fonts.googleapis.com 的文件，具体请参考 sxbxjhwm&lt;/p&gt;&#10;&lt;h2 id="验证是否生效"&gt;验证是否生效&#10;&lt;/h2&gt;&lt;p&gt;保存后，刷新后台，查看源代码，如果存在以下代码则表示成功：&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="https://zhangge.net/img/uploads/2014/06/googlefonts4.png" target="_blank" rel="noopener"&#10; &gt;&lt;img alt="googlefonts4" loading="lazy" sizes="(max-width: 767px) calc(100vw - 30px), (max-width: 1023px) 700px, (max-width: 1279px) 950px, 1232px" src="https://zhangge.net/img/uploads/2014/06/googlefonts4-300x170.png"&gt;&lt;/a&gt;**Ps：①、如果找不到，请检查之前是否已经禁用了Open Sans 功能，如果是，请先解除禁用：删除 functions.php 里面的禁用代码或删除 WP 相关插件即可；****②、此方法在 WordPress 升级后将会失效，期待 php 能人可以写一个主题函数，转换下这个链接，一劳永逸；**③、**最新发现：发现镜像加速后的文件里面，依然存在谷歌的在线链接：http://themes.googleusercontent.com/***，所以此方法宣布“破产”，真蛋疼！**&lt;strong&gt;写在最后：&lt;/strong&gt;&lt;/p&gt;&#10;&lt;h2 id="懒人方案与自建方法"&gt;懒人方案与自建方法&#10;&lt;/h2&gt;&lt;p&gt;如果你觉得麻烦，你可以直接使用张戈博客提供的七牛空间地址。&lt;/p&gt;&#10;&lt;p&gt;如果你是一个爱折腾的人，那么可以自己去新建一个七牛空间来完成加速。&lt;/p&gt;&#10;&lt;p&gt;如果你还没有七牛账号，那么请 &lt;a class="link" href="https://portal.qiniu.com/signup?code=3lgiiufrno1ua" title="前往注册七牛免费加速账号"&#10; target="_blank" rel="noopener"&#10; &gt;点此链接&lt;/a&gt; 注册一个，顺便给张戈带来点注册奖励，也不错哈！&lt;/p&gt;&#10;</description></item></channel></rss>