WordPress 4.6 以后的版本会在头部添加 dns-prefetch,应该是为了从 s.w.org 预获取表情和头像提高网页加载速度,但国内根本无法访问所以预获取和提高速度就无从谈起,荒岛本次带来 WordPress 禁止头部加载 dns-prefetch 样式的教程,只要将下面的代码添加到主题的「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 );宝藏内容来自荒岛-https://x-imagine.com/wordpress-disable-dns-prefetch.html宝藏内容来自荒岛-https://x-imagine.com/wordpress-disable-dns-prefetch.html
请按「Ctrl+D」收藏荒岛分享给好友,如您发现本文教程或宝藏链接已失效,请联系站长修正!
荒岛公众号
扫一扫关注

HDsoft27
公众号ID已复制,前往微信关注...
荒岛哔哩姬
扫一扫关注

ximagine
哔哩姬ID已复制,前往B站关注...