s.w.org

移除WordPress头部的window._wpemojiSettings代码及dns-prefetch

星期四, 十二月 12th, 2019 | wordpress | 没有评论

升级到新版的wordpress的,看了下页面好多emojo的 js定义代码,对我也没有多大用,移除之.

头部还添加了dns-prefetch,从s.w.org预获取表情和头像,但s.w.org国内无法访问也是浪费.

在主题编辑 functions.php 文件中最后添加即可

//remove emoji
remove_action( 'admin_print_scripts', 'print_emoji_detection_script');
remove_action( 'admin_print_styles', 'print_emoji_styles');
remove_action( 'wp_head', 'print_emoji_detection_script', 7);
remove_action( 'wp_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 dns-prefetch
remove_action( 'wp_head', 'wp_resource_hints', 2 );

刷新页面可以看到那一堆js消失了.

Tags: , ,

Search

文章分类

Links

Meta