方法其实很简单,在wordpress的当前主题函数文件functions.php当中添加这组代码并保存即可:
//移除头部dns-prefetch
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 );
是不是很简单?
评论抢沙发