WordPress在头部多出来一个s.w.org的加载,是为了从s.w.org预获取表情和头像,但是在国内不仅没用处,反而可能会影响速度,那就禁止它。
将下面的代码添加到主题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