禁止wordpress仪表盘加载谷歌字体链接

  • 时间:2020-05-27 19:03:24
  • 分类:网络文摘
  • 阅读:155 次

细心的朋友或许会发现近来登录wordpress后,仪表盘页面的加载速度明显变缓,这是由于wordpress仪表盘加载谷歌字体链接的原因,会经常导致页面卡在 fonts.googleapis.com 链接上。众所周知,谷歌服务在国内访问很不稳定,加载此链接严重影响后台页面显示速度。解决此问题的方法如下:

禁止wordpress仪表盘加载谷歌字体链接

禁止wordpress仪表盘加载谷歌字体链接

粘贴如下代码到当前主题的functions.php文件中:

  1. function coolwp_remove_open_sans_from_wp_core() {
  2.     wp_deregister_style( 'open-sans' );
  3.     wp_register_style( 'open-sans', false );
  4.     wp_enqueue_style('open-sans','');
  5. }
  6. add_action( 'init', 'coolwp_remove_open_sans_from_wp_core' );

重新登录wordpress后台,页面加载速度明显提升。

以上代码来源于 Remove Open Sans font from WP core 插件,也可直接安装此插件来解决。相似功能的插件还有 Disable Google Fonts 。

另外,一些国外主题也经常采用谷歌字体链接,上述方法貌似对前台主题加载谷歌字体链接无效。

注:wordpress加载谷歌字体代码位于:wordpress\wp-includes\script-loader.php第580行。

推荐阅读:
Listen to what an SEO expert has to say about its benefits  Depth First Search Algorithm to Compute the Smallest String Star  Algorithm to Check if All Points are On the Same Line  Prefix Sum Algorithm to Count Number of Nice Subarrays  How to Append Another List to a Existing List in Python? (Differ  Linear Algorithm to Check If All 1’s Are at Least Length K  Finding the Root of a Tree (Finding the Common Destination)  Does WIFI Extender Boost Wireless Signal? How to Fix Slow WIFI?  Bruteforce with Memoization to Count the Square Digit Chains  How to Merge Two List/Iterators in Java? 
评论列表
添加评论