码迷,mamicode.com
首页 > 其他好文 > 详细

替换WordPress调用的Google前端库为360镜像的库

时间:2015-04-25 00:30:24      阅读:200      评论:0      收藏:0      [点我收藏+]

标签:

把 googleapis 替换成 useso 即可:
sed -i s/googleapis/useso/g `grep -rl googleapis ./wordpress`
另外在后台关闭Gravatar头像显示(设置-讨论-头像显示),免得拖慢页面加载速度.
要成倍提升WordPress速度,可以考虑使用PHP7开发版,参考:
http://my.oschina.net/eechen/blog/298027

查看哪些文件在哪些行包含了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‘);

替换WordPress调用的Google前端库为360镜像的库

标签:

原文地址:http://my.oschina.net/eechen/blog/406115

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!