WordPress禁用Emoji表情提升访问速度

WordPress是我这么多年来最喜欢的一款程序,不管大家如何抱怨它的臃肿,以及各种外部资源加载,我仍然热情的拥抱它,毕竟除了这两点,WordPress还是非常完美的。

事实上WordPress的这些小缺点也是可以解决的,关键就在于站长够不够勤奋,这里要说的是禁用Emoji表情的方法。

对于我的博客,Emoji表情是用不上了,又何必为了一个不常用的功能而牺牲性能呢?请看禁用Emoji表情代码:

function bzg_disable_emojis() {
	remove_action( 'wp_head', 'print_emoji_detection_script', 7 );
	remove_action( 'admin_print_scripts', 'print_emoji_detection_script' );
	remove_action( 'wp_print_styles', 'print_emoji_styles' );
	remove_action( 'admin_print_styles', 'print_emoji_styles' );
	remove_filter( 'the_content_feed', 'wp_staticize_emoji' );
	remove_filter( 'comment_text_rss', 'wp_staticize_emoji' );
	remove_filter( 'wp_mail', 'wp_staticize_emoji_for_email' );
	remove_action( 'wp_head', 'wp_resource_hints', 2 );
}
add_action( 'init', 'bzg_disable_emojis' );

将以上代码丢到主题文件functions.php中即可。

阿里云