WordPress速度非常慢,后台加载ajax.googleapis.com解决,替换cdnjs.net办法

刚开始装了‘Disable Google Fonts’ 这个插件,根本没有作用,所以还是手动修改吧

找到wp-includes下面的script-loader.php,查找字符串 ‘ajax.googleapis.com’ 找到下面那段代码
把下面这段全部屏蔽掉在前面加//
或者直接替换掉

$scripts->add( 'prototype', '//cdn.cdnjs.net/prototype/1.7.1.0/prototype.js', array(), '1.7.1');  
$scripts->add( 'scriptaculous-root', '//cdn.cdnjs.net/scriptaculous/1.9.0/scriptaculous.js', array('prototype'), '1.9.0');  
$scripts->add( 'scriptaculous-builder', '//cdn.cdnjs.net/scriptaculous/1.9.0/builder.js', array('scriptaculous-root'), '1.9.0');  
$scripts->add( 'scriptaculous-dragdrop', '//cdn.cdnjs.net/scriptaculous/1.9.0/dragdrop.js', array('scriptaculous-builder', 'scriptaculous-effects'), '1.9.0');  
$scripts->add( 'scriptaculous-effects', '//cdn.cdnjs.net/scriptaculous/1.9.0/effects.js', array('scriptaculous-root'), '1.9.0');  
$scripts->add( 'scriptaculous-slider', '//cdn.cdnjs.net/scriptaculous/1.9.0/slider.js', array('scriptaculous-effects'), '1.9.0');  
$scripts->add( 'scriptaculous-sound', '//cdn.cdnjs.net/scriptaculous/1.9.0/sound.js', array( 'scriptaculous-root' ), '1.9.0' );  
$scripts->add( 'scriptaculous-controls', '//cdn.cdnjs.net/scriptaculous/1.9.0/controls.js', array('scriptaculous-root'), '1.9.0');

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

function hc_cdn_callback($buffer) {
    return str_replace('cdn.bootcss.com/jqueryui/1.12.1/jquery-ui.min.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');

Share

prrx

自信,认真,乐观,多愁善感的,复合型男人

You may also like...

发表评论

邮箱地址不会被公开。 必填项已用*标注