替换WordPress调用的Google前端库为360镜像的库
博客专区 > eechen 的博客 > 博客详情
替换WordPress调用的Google前端库为360镜像的库
eechen 发表于3年前
替换WordPress调用的Google前端库为360镜像的库
  • 发表于 3年前
  • 阅读 1547
  • 收藏 7
  • 点赞 0
  • 评论 3
把 googleapis 替换成 useso 即可:
sed -i s/googleapis/useso/g `grep -rl googleapis ./wordpress`
另外在后台关闭Gravatar头像显示(设置-讨论-头像显示),免得拖慢页面加载速度.
要成倍提升WordPress速度,可以考虑使用PHP7,参考:
http://my.oschina.net/eechen/blog/411534

查看哪些文件在哪些行包含了googleapis串:
grep -rn googleapis ./wordpress-4.2
./wp-admin/css/press-this-editor.css:9: @import url("//fonts.googleapis.com/css?family=Open+Sans:400italic,700italic,400,600,700");
./wp-admin/css/press-this-editor-rtl.css:9: @import url("//fonts.googleapis.com/css?family=Open+Sans:400italic,700italic,400,600,700");
./wp-includes/script-loader.php:153:    $scripts->add( 'prototype', '//ajax.googleapis.com/ajax/libs/prototype/1.7.1.0/prototype.js', array(), '1.7.1');
./wp-includes/script-loader.php:154:    $scripts->add( 'scriptaculous-root', '//ajax.googleapis.com/ajax/libs/scriptaculous/1.9.0/scriptaculous.js', array('prototype'), '1.9.0');
./wp-includes/script-loader.php:155:    $scripts->add( 'scriptaculous-builder', '//ajax.googleapis.com/ajax/libs/scriptaculous/1.9.0/builder.js', array('scriptaculous-root'), '1.9.0');
./wp-includes/script-loader.php:156:    $scripts->add( 'scriptaculous-dragdrop', '//ajax.googleapis.com/ajax/libs/scriptaculous/1.9.0/dragdrop.js', array('scriptaculous-builder', 'scriptaculous-effects'), '1.9.0');
./wp-includes/script-loader.php:157:    $scripts->add( 'scriptaculous-effects', '//ajax.googleapis.com/ajax/libs/scriptaculous/1.9.0/effects.js', array('scriptaculous-root'), '1.9.0');
./wp-includes/script-loader.php:158:    $scripts->add( 'scriptaculous-slider', '//ajax.googleapis.com/ajax/libs/scriptaculous/1.9.0/slider.js', array('scriptaculous-effects'), '1.9.0');
./wp-includes/script-loader.php:159:    $scripts->add( 'scriptaculous-sound', '//ajax.googleapis.com/ajax/libs/scriptaculous/1.9.0/sound.js', array( 'scriptaculous-root' ), '1.9.0' );
./wp-includes/script-loader.php:160:    $scripts->add( 'scriptaculous-controls', '//ajax.googleapis.com/ajax/libs/scriptaculous/1.9.0/controls.js', array('scriptaculous-root'), '1.9.0');
./wp-includes/script-loader.php:650:    $open_sans_font_url = "//fonts.googleapis.com/css?family=Open+Sans:300italic,400italic,600italic,300,400,600&subset=$subsets";
./wp-includes/js/tinymce/plugins/compat3x/css/dialog.css:1: @import url(//fonts.googleapis.com/css?family=Open+Sans:300italic,400italic,600italic,300,400,600&subset=latin-ext,latin);
./wp-content/themes/twentyfifteen/functions.php:201:        ), '//fonts.googleapis.com/css' );
./wp-content/themes/twentyfifteen/genericons/example.html:6:<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
./wp-content/themes/twentythirteen/functions.php:149:        $fonts_url = add_query_arg( $query_args, '//fonts.googleapis.com/css' );
./wp-content/themes/twentyfourteen/functions.php:218:        $font_url = add_query_arg( $query_args, '//fonts.googleapis.com/css' );

可以考虑使用下载到本地的JS文件并且禁用在线字体:
引入字体的地方可以注释掉,变量则置为空.
JS文件则替换为本地文件:
cd wordpress && mkdir ajax
wget \
ajax.useso.com/ajax/libs/prototype/1.7.1.0/prototype.js \
ajax.useso.com/ajax/libs/scriptaculous/1.9.0/scriptaculous.js \
ajax.useso.com/ajax/libs/scriptaculous/1.9.0/builder.js \
ajax.useso.com/ajax/libs/scriptaculous/1.9.0/dragdrop.js \
ajax.useso.com/ajax/libs/scriptaculous/1.9.0/effects.js \
ajax.useso.com/ajax/libs/scriptaculous/1.9.0/slider.js \
ajax.useso.com/ajax/libs/scriptaculous/1.9.0/sound.js \
ajax.useso.com/ajax/libs/scriptaculous/1.9.0/controls.js \
ajax.useso.com/ajax/libs/jquery/1.7.2/jquery.min.js
./wp-includes/script-loader.php 里改为:
$scripts->add( 'prototype', '/ajax/prototype.js', array(), '1.7.1');
$scripts->add( 'scriptaculous-root', '/ajax/scriptaculous.js', array('prototype'), '1.9.0');
$scripts->add( 'scriptaculous-builder', '/ajax/builder.js', array('scriptaculous-root'), '1.9.0');
$scripts->add( 'scriptaculous-dragdrop', '/ajax/dragdrop.js', array('scriptaculous-builder', 'scriptaculous-effects'), '1.9.0');
$scripts->add( 'scriptaculous-effects', '/ajax/effects.js', array('scriptaculous-root'), '1.9.0');
$scripts->add( 'scriptaculous-slider', '/ajax/slider.js', array('scriptaculous-effects'), '1.9.0');
$scripts->add( 'scriptaculous-sound', '/ajax/sound.js', array( 'scriptaculous-root' ), '1.9.0' );
$scripts->add( 'scriptaculous-controls', '/ajax/controls.js', array('scriptaculous-root'), '1.9.0');
共有 人打赏支持
eechen
粉丝 928
博文 106
码字总数 55593
作品 1
评论 (3)
snowdream
不错,最好能封装成插件,呵呵~
holdlg

引用来自“snowdream”的评论

不错,最好能封装成插件,呵呵~
Google Font Fix
×
eechen
如果觉得我的文章对您有用,请随意打赏。您的支持将鼓励我继续创作!
* 金额(元)
¥1 ¥5 ¥10 ¥20 其他金额
打赏人
留言
* 支付类型
微信扫码支付
打赏金额:
已支付成功
打赏金额: