是不是觉得WordPress打开网站的速度慢,那么你可以通过以下的方法精简WordPress自己加载的JQuery库,当然,一定要不影响你的网站的正常功能。
//精简头部信息 remove_action( 'wp_head', 'wp_enqueue_scripts', 1 ); //Javascript的调用 remove_action( 'wp_head', 'feed_links', 2 ); //移除feed remove_action( 'wp_head', 'feed_links_extra', 3 ); //移除feed remove_action( 'wp_head', 'rsd_link' ); //移除离线编辑器开放接口 remove_action( 'wp_head', 'wlwmanifest_link' ); //移除离线编辑器开放接口 remove_action( 'wp_head', 'index_rel_link' ); //去除本页唯一链接信息 remove_action('wp_head', 'parent_post_rel_link', 10, 0); //清除前后文信息 remove_action('wp_head', 'start_post_rel_link', 10, 0); //清除前后文信息 remove_action( 'wp_head', 'adjacent_posts_rel_link_wp_head', 10,0 ); remove_action( 'wp_head', 'locale_stylesheet' ); remove_action('publish_future_post','check_and_publish_future_post',10,1 ); remove_action( 'wp_head', 'noindex', 1 ); remove_action( 'wp_head', 'wp_print_styles', 8 ); //载入css remove_action( 'wp_head', 'wp_print_head_scripts', 9 ); remove_action( 'wp_head', 'wp_generator' ); //移除WordPress版本 remove_action( 'wp_head', 'rel_canonical' ); remove_action( 'wp_footer', 'wp_print_footer_scripts' ); remove_action( 'wp_head', 'wp_shortlink_wp_head', 10, 0 ); remove_action( 'template_redirect', 'wp_shortlink_header', 11, 0); add_action('widgets_init','my_remove_recent_comments_style'); function my_remove_recent_comments_style() { global $wp_widget_factory; remove_action('wp_head',array($wp_widget_factory->widgets['WP_Widget_Recent_Comments'],'recent_comments_style')); } //禁止加载WP自带的jquery.js if ( !is_admin() ) { // 后台不禁止 function my_init_method() { wp_deregister_script( 'jquery' ); // 取消原有的 jquery 定义 } add_action('init', 'my_init_method'); } wp_deregister_script( 'l10n' );
评论前必须登录!
注册