网络营销电子商务研究中心  
How to buy the best prescription safety glasses in Canada? Let's study!
Go Back   网络营销电子商务研究中心 > 网站建设 > WordPress
User Name
Password
 
FAQ Members List Calendar Cheap Glasses

Reply
 
Thread Tools Display Modes
  #1   IP: 49.87.51.150
Old 2015-12-04, 05:13 AM
Gabriela Gabriela is offline
初级会员
 
Join Date: 2009-01-19
Posts: 1
Gabriela 现在声名狼藉
Default 一直加载“fonts.googleapis.com”的解决办法

最近国内对google又开始了新一轮的屏蔽,很多wordpress用户发现一个现象,那就是网站前台和后台打开都非常慢,仔细观察,会发现每次都是加载fonts.googleapis.com时卡在这里。那这个是什么原因呢?又该如何解决呢?

代明博客也遇到了同样的问题,试过好几种方法,最终的解决方法是修改一部分css和php,并且注释掉fonts.googleapis.com有关的内容。下面分别为大家说明。

首先看 如何解决一直加载“fonts.googleapis.com” 。

第一步,新建google-font.css 放在\wp-includes\css目录中(附该css文件的内容如下):

Code:
@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 文件,找到:
Code:
$open_sans_font_url = "//fonts.googleapis.com/css?family=Open+Sans:300italic,400italic,600italic,300,400,600&subset=$subsets";
替换成:
Code:
$open_sans_font_url = "/wp-includes/css/google-font.css";
第三步,在WordPress模板文件中找到functions.php,使用“//”注释掉引用google字体库部分即可。这里根据每个模板的不同而有所差异,代明博客的是下面这里:
Code:
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提供的大多少网络服务都比较慢,建议最好不要使用。
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Prescription-glasses.com offers prescription glasses online at discount prices.
All times are GMT +8. The time now is 10:43 AM.


Powered by vBulletin Version 3.8.7
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.