一直加载“fonts.googleapis.com”的解决办法
2014-10-18 17:05
399 查看
原文:http://www.tuicool.com/articles/6bayeq
最近国内对google又开始了新一轮的屏蔽,很多wordpress用户发现一个现象,那就是网站前台和后台打开都非常慢,仔细观察,会发现每次都是加载fonts.googleapis.com时卡在这里。那这个是什么原因呢?又该如何解决呢?
代明博客也遇到了同样的问题,试过好几种方法,最终的解决方法是修改一部分css和php,并且注释掉fonts.googleapis.com有关的内容。下面分别为大家说明。
首先看 如何解决一直加载“fonts.googleapis.com” 。
第一步,新建google-font.css 放在\wp-includes\css目录中(附该css文件的内容如下):
@font-face {
font-family: ‘Open Sans’;
font-style: normal;
font-weight: 300;
src: local(‘Open Sans Light’), local(‘OpenSans-Light’), url(../fonts/google/DXI1ORHCpsQm3Vp6mXoaTRa1RVmPjeKy21_GQJaLlJI.woff) format(‘woff’);
}
@font-face {
font-family: ‘Open Sans’;
font-style: normal;
font-weight: 400;
src: local(‘Open Sans’), local(‘OpenSans’), url(../fonts/google/u-WUoqrET9fUeobQW7jkRT8E0i7KZn-EPnyo3HZu7kw.woff) format(‘woff’);
}
@font-face {
font-family: ‘Open Sans’;
font-style: normal;
font-weight: 600;
src: local(‘Open Sans Semibold’), local(‘OpenSans-Semibold’), url(../fonts/google/MTP_ySUJH_bn48VBG8sNSha1RVmPjeKy21_GQJaLlJI.woff) format(‘woff’);
}
@font-face {
font-family: ‘Open Sans’;
font-style: italic;
font-weight: 300;
src: local(‘Open Sans Light Italic’), local(‘OpenSansLight-Italic’), url(../fonts/google/PRmiXeptR36kaC0GEAetxrsuoFAk0leveMLeqYtnfAY.woff) format(‘woff’);
}
@font-face {
font-family: ‘Open Sans’;
font-style: italic;
font-weight: 400;
src: local(‘Open Sans Italic’), local(‘OpenSans-Italic’), url(../fonts/google/xjAJXh38I15wypJXxuGMBtIh4imgI8P11RFo6YPCPC0.woff) format(‘woff’);
}
@font-face {
font-family: ‘Open Sans’;
font-style: italic;
font-weight: 600;
src: local(‘Open Sans Semibold Italic’), local(‘OpenSans-SemiboldItalic’), url(../fonts/google/PRmiXeptR36kaC0GEAetxmWeb5PoA5ztb49yLyUzH1A.woff) format(‘woff’);
}
第二步,修改 \wp-includes\script-loader.php 文件,找到:
$open_sans_font_url = “//fonts.googleapis.com/css?family=Open+Sans:300italic,400italic,600italic,300,400,600&subset=$subsets”;
替换成:
$open_sans_font_url = “/wp-includes/css/google-font.css”;
第三步,在WordPress模板文件中找到functions.php,使用“//”注释掉引用google字体库部分即可。这里根据每个模板的不同而有所差异,代明博客的是下面这里:
function govpress_fonts() {
// Add Genericons font, used in the main stylesheet.
// wp_enqueue_style( ‘fontawesome’, get_template_directory_uri() . ‘/fonts/font-awesome/font-awesome.css’, array(), ’4.0.3′ );
// wp_register_style( ‘govpress-open-sans’, ‘//fonts.googleapis.com/css?family=Open+Sans:300italic,400italic,600italic,700italic,400,600,700,300′, ”, null, ‘screen’ );
// wp_enqueue_style( ‘govpress-open-sans’ );
OK,现在是不是没有加载fonts.googleapis.com了呢?问题解决了。
那么 出现这个的原因是什么呢 ?
究其原因,就是最近Google https服务被屏蔽,部分网站会受影响。博客主题中引用了google字体库(fonts.googleapis.com)中的字体,导致网站打开速度超级慢,在国内使用google提供的大多少网络服务都比较慢,建议最好不要使用。
最近国内对google又开始了新一轮的屏蔽,很多wordpress用户发现一个现象,那就是网站前台和后台打开都非常慢,仔细观察,会发现每次都是加载fonts.googleapis.com时卡在这里。那这个是什么原因呢?又该如何解决呢?
代明博客也遇到了同样的问题,试过好几种方法,最终的解决方法是修改一部分css和php,并且注释掉fonts.googleapis.com有关的内容。下面分别为大家说明。
首先看 如何解决一直加载“fonts.googleapis.com” 。
第一步,新建google-font.css 放在\wp-includes\css目录中(附该css文件的内容如下):
@font-face {
font-family: ‘Open Sans’;
font-style: normal;
font-weight: 300;
src: local(‘Open Sans Light’), local(‘OpenSans-Light’), url(../fonts/google/DXI1ORHCpsQm3Vp6mXoaTRa1RVmPjeKy21_GQJaLlJI.woff) format(‘woff’);
}
@font-face {
font-family: ‘Open Sans’;
font-style: normal;
font-weight: 400;
src: local(‘Open Sans’), local(‘OpenSans’), url(../fonts/google/u-WUoqrET9fUeobQW7jkRT8E0i7KZn-EPnyo3HZu7kw.woff) format(‘woff’);
}
@font-face {
font-family: ‘Open Sans’;
font-style: normal;
font-weight: 600;
src: local(‘Open Sans Semibold’), local(‘OpenSans-Semibold’), url(../fonts/google/MTP_ySUJH_bn48VBG8sNSha1RVmPjeKy21_GQJaLlJI.woff) format(‘woff’);
}
@font-face {
font-family: ‘Open Sans’;
font-style: italic;
font-weight: 300;
src: local(‘Open Sans Light Italic’), local(‘OpenSansLight-Italic’), url(../fonts/google/PRmiXeptR36kaC0GEAetxrsuoFAk0leveMLeqYtnfAY.woff) format(‘woff’);
}
@font-face {
font-family: ‘Open Sans’;
font-style: italic;
font-weight: 400;
src: local(‘Open Sans Italic’), local(‘OpenSans-Italic’), url(../fonts/google/xjAJXh38I15wypJXxuGMBtIh4imgI8P11RFo6YPCPC0.woff) format(‘woff’);
}
@font-face {
font-family: ‘Open Sans’;
font-style: italic;
font-weight: 600;
src: local(‘Open Sans Semibold Italic’), local(‘OpenSans-SemiboldItalic’), url(../fonts/google/PRmiXeptR36kaC0GEAetxmWeb5PoA5ztb49yLyUzH1A.woff) format(‘woff’);
}
第二步,修改 \wp-includes\script-loader.php 文件,找到:
$open_sans_font_url = “//fonts.googleapis.com/css?family=Open+Sans:300italic,400italic,600italic,300,400,600&subset=$subsets”;
替换成:
$open_sans_font_url = “/wp-includes/css/google-font.css”;
第三步,在WordPress模板文件中找到functions.php,使用“//”注释掉引用google字体库部分即可。这里根据每个模板的不同而有所差异,代明博客的是下面这里:
function govpress_fonts() {
// Add Genericons font, used in the main stylesheet.
// wp_enqueue_style( ‘fontawesome’, get_template_directory_uri() . ‘/fonts/font-awesome/font-awesome.css’, array(), ’4.0.3′ );
// wp_register_style( ‘govpress-open-sans’, ‘//fonts.googleapis.com/css?family=Open+Sans:300italic,400italic,600italic,700italic,400,600,700,300′, ”, null, ‘screen’ );
// wp_enqueue_style( ‘govpress-open-sans’ );
OK,现在是不是没有加载fonts.googleapis.com了呢?问题解决了。
那么 出现这个的原因是什么呢 ?
究其原因,就是最近Google https服务被屏蔽,部分网站会受影响。博客主题中引用了google字体库(fonts.googleapis.com)中的字体,导致网站打开速度超级慢,在国内使用google提供的大多少网络服务都比较慢,建议最好不要使用。
相关文章推荐
- fonts.googleapis.com加载慢的解决办法
- fonts.googleapis.com加载慢解决办法
- fonts.googleapis.com, ajax.googleapis.com加载缓慢的解决方法
- https://fonts.googleapis.com/css 一直加载的处理
- fonts.googleapis.com ajax.googleapis.com wordpress加载慢的解决方法【转】
- fonts.googleapis.com ajax.googleapis.com wordpress加载慢的解决方法
- 黄聪:wordpress后台导致fonts.googleapis.com、ajax.googleapis.com加载慢的解决方法
- 访问网站*.googleapis.com加载慢,解决办法
- fonts.googleapis.com 加载慢的解决方法
- 解决Odoo访问fonts.googleapis.com导致速度慢的问题
- fonts.googleapis.com 字体报错问题解决。
- Joomla使用ajax.googleapis.com导致网页加载非常慢的解决方法
- fonts.googleapis.com 谷歌字体库加载过慢解决方案
- 解决wordpress的fonts.googleapis.com在国内无法访问的问题
- fonts.googleapis.com不能访问时的解决方法
- 原 ajax.googleapis.com等公共库加载被“墙”的解决方法!
- 黄聪:如何删除wordpress登录之后wp_footer、wp_head自行加载的Open Sans字体、fonts.googleapis.com连接导致卡死的问题
- Wordpress 打开首页老是加载themes.googleusercontent.com 的解决办法
- 解决fonts.googleapis.com不能访问,导致网页打不开