关于wordpress后台首页加载ajax.googleapis特别慢的解决办法

通过审查元素发现,拖慢后台加载速度的主要是两个路径

1.https://ajax.googleapis.com/ajax/libs/prototype/1.7.1.0/prototype.js

2.http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.21/themes/smoothness/jquery-ui.css

都是谷歌的,现在国内访问谷歌几乎是访问不了,必须要FQ才可以,下面是解决这两东西的办法

第一种:

  通过wordpress后台安装 ‘Disable Google Fonts’ 这个插件,这是最简单的解决办法,网上大多都是用的这个,不过我测试了一下,没有效果,没起效果的接着往下看!

第二种:

  1.首先解决prototype.js,找到wp-includes下面的script-loader.php,查找字符串 ‘prototype’ 

$scripts->add( 'prototype', 'http://cdn.bootcss.com/prototype/1.7.3/prototype.min.js', array(), '1.7.3');

我们换成bootstrap的cdn加速代码

  2.解决jquery-ui.css,找到wp-includes下面的functions.php文件,在最下面添加如下代码,思路就是替换

function hc_cdn_callback($buffer) {
    return str_replace('ajax.googleapis.com/ajax/libs/jqueryui/1.8.21/themes/smoothness/jquery-ui.css', 'cdn.bootcss.com/jqueryui/1.12.1/jquery-ui.min.css', $buffer);//主要是修改这行
}
function hc_buffer_start() {
    ob_start("hc_cdn_callback");
}
function izt_buffer_end() {
    ob_end_flush();
}
add_action('init', 'hc_buffer_start');
add_action('shutdown', 'hc_buffer_end');

查看你的具体字符串格式,可能需要进行修改一点内容!

有更好的方法还请分享一下,如有错误还请指出,谢谢!

 

posted @ 2017-08-09 13:55  叶小凡  阅读(4870)  评论(4编辑  收藏  举报