WP清理、加速 2014-05-07 @ TECH admin-headerCDNremove_actionwordpresswp_headwp-login优化删除open-sans加速3
一、加速
主要JS全部走CDN,几个常用JS加速CDN推荐:
七牛CDN: http://www.staticfile.org/
又拍云JS库: http://jscdn.upai.com/
BAE公共库: http://developer.baidu.com/wiki/index.php?title=docs/cplat/libs
SAE公共资源: http://sae.sina.com.cn/doc/services/libraries.html
当前模版中functions.php,清理html代码:
clear_head(); function clear_head() { remove_action( 'wp_head', 'feed_links_extra', 3 ); remove_action( 'wp_head', 'feed_links', 2 ); remove_action( 'wp_head', 'rsd_link' ); remove_action( 'wp_head', 'wlwmanifest_link' ); remove_action( 'wp_head', 'adjacent_posts_rel_link_wp_head', 10, 0 ); remove_action( 'wp_head', 'wp_generator' ); remove_action( 'wp_head', 'rel_canonical' ); remove_action( 'wp_head', 'wp_shortlink_wp_head' ); }
替换主要JS,并在代码最后调用
add_action( 'get_footer' , 'bootstrap_js' ); function bootstrap_js() { wp_deregister_script( 'jquery' ); wp_register_script( 'jquery', 'http://cdn.staticfile.org/jquery/1.8.3/jquery.min.js' ); wp_enqueue_script( 'jquery' ); wp_register_script( 'bootstrap', 'http://cdn.staticfile.org/twitter-bootstrap/3.0.0/js/bootstrap.min.js' ); wp_enqueue_script( 'bootstrap' ); }
二、去掉gooleapi的fonts
因为众所周知的原因,googleapis在国内的速度实在太慢,把网站速度托慢了太多,比如open-sans、jquery等的调用
后台去掉open-sans,需要修改2个地方:
wp-login.php 找到 wp_admin_css( 'login', true ); 到此行之上追加 wp_deregister_style('open-sans'); wp_register_style('open-sans',false); wp-admin/admin-header.php 找到 wp_enqueue_style( 'colors' ); 到此行之上追加 wp_deregister_style('open-sans'); wp_register_style('open-sans',false);
前台模版中有用到的方法也类似,可以google一下”wordpress remove open-sans”
具体您所说的方式? 是直接在自己主题中的functions.php中加入代码即可?? 本人是前端,不太了解
如果是原创,给你点32个赞