WordPress如何禁用s.w.org预加载

admin
admin
管理员
88
文章
0
粉丝
wordpress评论367字数 148阅读0分29秒
WordPress如何禁用s.w.org预加载
WordPress如何禁用s.w.org预加载

WordPress从 WordPress 4.6 版本开始,头部会以dns-prefetch的形式从 s.w.org 预获取表情和头像,目的是提高网页加载速度 ,但 s.w.org 国内根本无法访问。所以这个功能就显得很鸡肋。

想要禁用它也很简单,将下面的代码复制到位于主题目录functions.php文件里面就可以了。文章源自零捌陆工作室-https://www.086026.com/78.html

//移除 WordPress 头部加载 DNS 预获取(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 );
文章源自零捌陆工作室-https://www.086026.com/78.html文章源自零捌陆工作室-https://www.086026.com/78.html
历年同日文章
12 月
2
weinxin
我的微信
微信号已复制
我的微信
微信扫一扫
 最后更新:2023-10-7
admin
  • 本文由 admin 发表于2020年12月2日 07:42:15
  • 转载请务必保留本文链接:https://www.086026.com/78.html

发表评论