wordpress中google的js公共库替换加速(不用360)
现在360的前端公共库已经关闭不能使用了,而google的js公共库访问速度又比较慢也不稳定。我们可以将其链接替换成cdnjs的公共库。
打开script-loader.php文件:
// $scripts->add( 'prototype', '//ajax.googleapis.com/ajax/libs/prototype/1.7.1.0/prototype.js', array(), '1.7.1'); // $scripts->add( 'scriptaculous-root', '//ajax.googleapis.com/ajax/libs/scriptaculous/1.9.0/scriptaculous.js', array('prototype'), '1.9.0'); // $scripts->add( 'scriptaculous-builder', '//ajax.googleapis.com/ajax/libs/scriptaculous/1.9.0/builder.js', array('scriptaculous-root'), '1.9.0'); // $scripts->add( 'scriptaculous-dragdrop', '//ajax.googleapis.com/ajax/libs/scriptaculous/1.9.0/dragdrop.js', array('scriptaculous-builder', 'scriptaculous-effects'), '1.9.0'); // $scripts->add( 'scriptaculous-effects', '//ajax.googleapis.com/ajax/libs/scriptaculous/1.9.0/effects.js', array('scriptaculous-root'), '1.9.0'); // $scripts->add( 'scriptaculous-slider', '//ajax.googleapis.com/ajax/libs/scriptaculous/1.9.0/slider.js', array('scriptaculous-effects'), '1.9.0'); // $scripts->add( 'scriptaculous-sound', '//ajax.googleapis.com/ajax/libs/scriptaculous/1.9.0/sound.js', array( 'scriptaculous-root' ), '1.9.0' ); // $scripts->add( 'scriptaculous-controls', '//ajax.googleapis.com/ajax/libs/scriptaculous/1.9.0/controls.js', array('scriptaculous-root'), '1.9.0');
将以上代码注释,替换成下面代码即可。
$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');
本文出处: