小十的个人博客

@小十

born for design, do what you want, and carpe diem

文章 343
朋友 17
来访 1840

LATEST POSTS

RANKINGS

    • http://www.xiaoten.com
    • 网站成立5538天

    小十

    • 收藏品

    利用360前端公共库 CDN 服务解决 GOOGLE 字体屏蔽

    自从 Google 被国内全面屏蔽以来,造成了谷歌的许多服务404了,这里就包括谷歌字体。这造成国内许多独立博客(尤其适用 WordPress 的)访问超级慢。当然也包括我的网站。

    当然我也采取了一些措施,例如:

    1、安装插件“ Disable Google Fonts ”,安装并激活。

    2、许多博主说的在主题fuctions.phg文件中添加以下代码:

    //禁用Open Sans
    class Disable_Google_Fonts {
    	public function __construct() {
    		add_filter( ‘gettext_with_context’, array( $this, ‘disable_open_sans’ ), 888, 4 );
    	}
    	public function disable_open_sans( $translations, $text, $context, $domain ) {
    		if ( ‘Open Sans font: on or off’ == $context && ‘on’ == $text ) {
    			$translations = ‘off’;
    		}
    		return $translations;
    	}
    }
    $disable_google_fonts = new Disable_Google_Fonts;

    不过据我测试,以上两种方法都没有什么实质的改善,依然有网友反映我的网站加载缓慢。好不容易备案了,用了国内的服务器,总不能比国外还差吧!今天终于找到一个好方法:使用 360 前端公共库 CDN 服务代理访问 Google 字体库。我使用了下,确实效果十足!(虽然我平时比较讨厌360,不过这个确实赞。)

    以下是具体的使用方法:

    第一种:修改网站目录文件  wp-includesscript-loader.php,找到:fonts.googleapis.com,替换成:fonts.useso.com。

    第二种:利用 WordPress 插件修改,插件下载地址:http://www.soulteary.com/wp-content/uploads/2014/06/Replace-Google-Fonts.zip (作者为了防盗链,请复制网址后再打开)

    插件说明地址:http://www.soulteary.com/2014/06/08/replace-google-fonts.html(感谢soulteary童鞋开发了这个插件)

    Comments | 2 条评论

      游客,你好 修改资料

    *邮箱和昵称必须填写