很多同学在wp博客上面都发现了这段代码吧
<link rel='dns-prefetch' href='//s.w.org'>
这个是为了预加载一些表情用的,但是在我们大天朝是用不上的,反而影响我们网站的速度,建议静止他
可在后台找到functions.php这个表,添加上
function remove_dns_prefetch( $hints, $relation_type ) { if ( 'dns-prefetch' === $relation_type ) { return array_diff( wp_dependencies_unique_hosts(), $hints ); } return $hints; } add_filter( 'wp_resource_hints', 'remove_dns_prefetch', 10, 2 );
上面这个是兼容性最好的,就是代码多了点,所以也可以用这个
remove_action( 'wp_head', 'wp_resource_hints', 2 );
这两种随便选一个添加就行了 最后再提供一个禁止加载表情的代码,我是已经添加上了的。
// Remove emoji script remove_action( 'wp_head', 'print_emoji_detection_script', 7 ); remove_action( 'wp_print_styles', 'print_emoji_styles' ); add_filter( 'emoji_svg_url', '__return_false' );
评论前必须登录!
注册