WordPress优化加速技巧:禁用谷歌字体

前端之家收集整理的这篇文章主要介绍了WordPress优化加速技巧:禁用谷歌字体前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

谷歌字体是个好东西,它能够让字体在网页上显示的丰富多样而且非常完美。wordpress自3.8版本以后加入了谷歌字体。在国内,谷歌的一系列网站被彻底墙,包括谷歌字体 Google Fonts 所在的googleapis.com 。因此,广大的站长朋友们使用完成以后,当上线打开WordPress 站点时,发现速度非常慢,根本原因是加载不了谷歌字体。这篇WordPress教程里,我们将向大家介绍一下WordPress禁止谷歌字体的方法。

,详情请点击前方的链接进行查看。

1. 插件解决方法,安装并启用 插件 或者 插件

2. 切换到主题目录,打开functions.PHP添加一个函数禁用,代码如下:

Crayon-5c891d165adea519707739" class="Crayon-Syntax Crayon-theme-classic Crayon-font-monaco Crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouSEOver" style=" margin-top: 12px; margin-bottom: 12px; font-size: 12px !important; line-height: 15px !important;">
Crayon-toolbar" data-settings=" mouSEOver overlay hide delay" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">Crayon-title">
Crayon-tools" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">Crayon-mixed-highlight" title="Contains Mixed Languages">
Crayon-button Crayon-nums-button" title="Toggle Line Numbers">
Crayon-button-icon">
Crayon-button Crayon-plain-button" title="Toggle Plain Code">
Crayon-button-icon">
Crayon-button Crayon-wrap-button" title="Toggle Line Wrap">
Crayon-button-icon">
Crayon-button Crayon-expand-button" title="Expand Code">
Crayon-button-icon">
Crayon-button Crayon-copy-button" title="Copy">
Crayon-button-icon">
Crayon-button Crayon-popup-button" title="Open Code In New Window">
Crayon-button-icon">
Crayon-info" style="min-height: 16.8px !important; line-height: 16.8px !important;">
Crayon-plain-wrap">
Crayon-main" style="">Crayon-table">Crayon-row">
Crayon-nums " data-settings="show">
Crayon-nums-content" style="font-size: 12px !important; line-height: 15px !important;">
Crayon-num" data-line="Crayon-5c891d165adea519707739-1">1
Crayon-num Crayon-striped-num" data-line="Crayon-5c891d165adea519707739-2">2
Crayon-num" data-line="Crayon-5c891d165adea519707739-3">3
Crayon-num Crayon-striped-num" data-line="Crayon-5c891d165adea519707739-4">4
Crayon-num" data-line="Crayon-5c891d165adea519707739-5">5
Crayon-num Crayon-striped-num" data-line="Crayon-5c891d165adea519707739-6">6
Crayon-num" data-line="Crayon-5c891d165adea519707739-7">7
Crayon-num Crayon-striped-num" data-line="Crayon-5c891d165adea519707739-8">8
Crayon-num" data-line="Crayon-5c891d165adea519707739-9">9
Crayon-num Crayon-striped-num" data-line="Crayon-5c891d165adea519707739-10">10
Crayon-code">
Crayon-pre" style="font-size: 12px !important; line-height: 15px !important; -moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4;">
Crayon-line" id="Crayon-5c891d165adea519707739-1">Crayon-ta">PHP
Crayon-line Crayon-striped-line" id="Crayon-5c891d165adea519707739-2">Crayon-e">add_filterCrayon-sy">(Crayon-h"> Crayon-s">'gettext_with_context'Crayon-sy">,Crayon-h"> Crayon-s">'Disable_Google_Fonts'Crayon-sy">,Crayon-h"> Crayon-cn">888Crayon-sy">,Crayon-h"> Crayon-cn">4Crayon-sy">)Crayon-sy">;
Crayon-line" id="Crayon-5c891d165adea519707739-3">Crayon-t">functionCrayon-h"> Crayon-e">Disable_Google_FontsCrayon-sy">(Crayon-v">$translationsCrayon-sy">,Crayon-h"> Crayon-v">$textCrayon-sy">,Crayon-h"> Crayon-v">$contextCrayon-sy">,Crayon-h"> Crayon-v">$domainCrayon-h"> Crayon-sy">)Crayon-h"> Crayon-sy">{
Crayon-line Crayon-striped-line" id="Crayon-5c891d165adea519707739-4">Crayon-h"> Crayon-v">$google_fonts_contextsCrayon-h"> Crayon-o">=Crayon-h"> Crayon-t">arrayCrayon-sy">(Crayon-s">'Open Sans font: on or off'Crayon-sy">,Crayon-s">'Lato font: on or off'Crayon-sy">,Crayon-s">'Source Sans Pro font: on or off'Crayon-sy">,Crayon-s">'Bitter font: on or off'Crayon-sy">)Crayon-sy">;
Crayon-line" id="Crayon-5c891d165adea519707739-5">Crayon-h"> Crayon-st">ifCrayon-sy">(Crayon-h"> Crayon-v">$textCrayon-h"> Crayon-o">==Crayon-h"> Crayon-s">'on'Crayon-h"> Crayon-o">&&Crayon-h"> Crayon-e">in_arrayCrayon-sy">(Crayon-v">$contextCrayon-sy">,Crayon-h"> Crayon-v">$google_fonts_contextsCrayon-h"> Crayon-sy">)Crayon-h"> Crayon-sy">)Crayon-sy">{
Crayon-line Crayon-striped-line" id="Crayon-5c891d165adea519707739-6">Crayon-h"> Crayon-v">$translationsCrayon-h"> Crayon-o">=Crayon-h"> Crayon-s">'off'Crayon-sy">;
Crayon-line" id="Crayon-5c891d165adea519707739-7">Crayon-h"> Crayon-sy">}
Crayon-line Crayon-striped-line" id="Crayon-5c891d165adea519707739-8">Crayon-h"> Crayon-k ">returnCrayon-h"> Crayon-v">$translationsCrayon-sy">;
Crayon-line" id="Crayon-5c891d165adea519707739-9">Crayon-sy">}
Crayon-line Crayon-striped-line" id="Crayon-5c891d165adea519707739-10">

nofollow">360网站卫士常用前端公共库CDN服务加载Google字体。

方法已失效,请勿向下阅读。

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

Crayon-5c891d165adf2343538390" class="Crayon-Syntax Crayon-theme-classic Crayon-font-monaco Crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouSEOver" style=" margin-top: 12px; margin-bottom: 12px; font-size: 12px !important; line-height: 15px !important;">
Crayon-toolbar" data-settings=" mouSEOver overlay hide delay" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">Crayon-title">
Crayon-tools" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
Crayon-button Crayon-nums-button" title="Toggle Line Numbers">
Crayon-button-icon">
Crayon-button Crayon-plain-button" title="Toggle Plain Code">
Crayon-button-icon">
Crayon-button Crayon-wrap-button" title="Toggle Line Wrap">
Crayon-button-icon">
Crayon-button Crayon-expand-button" title="Expand Code">
Crayon-button-icon">
Crayon-button Crayon-copy-button" title="Copy">
Crayon-button-icon">
Crayon-button Crayon-popup-button" title="Open Code In New Window">
Crayon-button-icon">
Crayon-info" style="min-height: 16.8px !important; line-height: 16.8px !important;">
Crayon-plain-wrap">
Crayon-main" style="">Crayon-table">Crayon-row">
Crayon-nums " data-settings="show">
Crayon-nums-content" style="font-size: 12px !important; line-height: 15px !important;">
Crayon-num" data-line="Crayon-5c891d165adf2343538390-1">1
Crayon-code">
Crayon-pre" style="font-size: 12px !important; line-height: 15px !important; -moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4;">
Crayon-line" id="Crayon-5c891d165adf2343538390-1">Crayon-sy">$Crayon-v">open_sans_font_urlCrayon-h"> Crayon-o">=Crayon-h"> Crayon-s">"//fonts.googleapis.com/css?family1=Open+Sans:300italic,600&subset=$subsets"Crayon-sy">;

把fonts.googleapis.com替换为fonts.useso.com,修改保存即可。

原文链接:https://www.f2er.com/wordpress/238453.html

猜你在找的wordpress相关文章