WordPress头部禁止s.w.org加载

WordPress在头部多出来一个s.w.org的加载,是为了从s.w.org预获取表情和头像,但是在国内不仅没用处,反而可能会影响速度,那就禁止它。

1532199480

将下面的代码添加到主题functions.php模板中:

//头部禁止s.w.org加载
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 );

 

本文来自投稿,不代表博客主立场,如若转载,请注明出处:https://www.bokezhu.com/2018/07/21/163.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
哇塞的头像哇塞认证作者
上一篇 2018/07/21 05:11
下一篇 2018/07/21 21:28

相关推荐

发表回复

登录后才能评论