WordPress 后台禁用Google Open Sans字体,加速网站

老虎说测试 脚本开发字数 1451阅读4分50秒阅读模式
摘要搞死人了,这几天GOOGLE好像又被~~~,痛苦的还是我们这些人啊,由于GOOGLE提供了很多便利的东西给我们引用,这下好了,弄得全部连接超时,访问起来速度比蜗牛还慢。wordpr...
WordPress 后台禁用Google Open Sans字体,加速网站

WordPress 后台禁用Google Open Sans字体

搞死人了,这几天GOOGLE好像又被~~~,痛苦的还是我们这些人啊,由于GOOGLE提供了很多便利的东西给我们引用,这下好了,弄得全部连接超时,访问起来速度比蜗牛还慢。wordpress后台自动加载google web font,所以这里,我们必须解决下。

两种方案:文章源自陈学虎-https://chenxuehu.com/article/2014/06/2676.html

第一,喜欢插件的便宜可以这么做:文章源自陈学虎-https://chenxuehu.com/article/2014/06/2676.html

解决方法很简单,安装启用 Disable Google Fonts 或者 Remove Open Sans font Link from WP core 其中之一即可。文章源自陈学虎-https://chenxuehu.com/article/2014/06/2676.html

不会安装插件的朋友可以留言哦~~~文章源自陈学虎-https://chenxuehu.com/article/2014/06/2676.html

 文章源自陈学虎-https://chenxuehu.com/article/2014/06/2676.html

第二种,代码解决方法:文章源自陈学虎-https://chenxuehu.com/article/2014/06/2676.html

在主题中的functions.php文件末尾加上:文章源自陈学虎-https://chenxuehu.com/article/2014/06/2676.html

代码1:文章源自陈学虎-https://chenxuehu.com/article/2014/06/2676.html

[php]
<pre class="html" style="color: #110000;">// Remove Open Sans that WP adds from frontend
if (!function_exists('remove_wp_open_sans')) :
function remove_wp_open_sans() {
wp_deregister_style( 'open-sans' );
wp_register_style( 'open-sans', false );
}
add_action('wp_enqueue_scripts', 'remove_wp_open_sans');文章源自陈学虎-https://chenxuehu.com/article/2014/06/2676.html

// Uncomment below to remove from admin
// add_action('admin_enqueue_scripts', 'remove_wp_open_sans');
endif;</pre>
[/php]文章源自陈学虎-https://chenxuehu.com/article/2014/06/2676.html

 

代码2

[php]
<pre class="html" style="color: #110000;">function remove_open_sans() {
wp_deregister_style( 'open-sans' );
wp_register_style( 'open-sans', false );
wp_enqueue_style('open-sans','');
}
add_action( 'init', 'remove_open_sans' );</pre>
[/php]

 

相信应该解决了您访问后台的问题了,不过此次的问题,对前台无影响!

 

最新第三种方法:

替换open sans 字体的加载源

打开wordpress代码中的文件wp-includes/script-loader.php文件,搜索:fonts.googleapis.com 找到这行代码:

[php]
$open_sans_font_url = "//fonts.googleapis.com/css?family1=Open+Sans:300italic,400italic,600italic,300,400,600&subset=$subsets";

[/php]

fonts.googleapis.com替换为fonts.useso.com

fonts.useso.com 是国内360推出的常用前端公共库CDN服务之一,“由于众所周知的原因,只需替换一个域名就可以继续使用Google提供的免费字体库了。同样,通过样式表引用这些资源,让网站访问速度瞬间提速吧骚年!”具体可以查看:http://libs.useso.com/。

 

 最后更新:2022-3-15
  • 版权声明:本文为原创文章,转载请附上原文出处链接及本声明。
  • 转载请注明:WordPress 后台禁用Google Open Sans字体,加速网站 | https://chenxuehu.com/article/2014/06/2676.html
评论  3  访客  2  作者  1