admin管理员组文章数量:1300110
How to remove this from WP head:
<link rel='dns-prefetch' href='//maps.google'>
I had this also:
<link rel='dns-prefetch' href='//s.w'>
But, I removed it with this code inside my functions.php
add_filter( 'emoji_svg_url', '__return_false' );
Probably, this is added by one plugin exifografy, which can show map of location where image is taken. But, there is just few posts with map, so having this on all URL-s is just one more line of not used HTML code.
How to remove this from WP head:
<link rel='dns-prefetch' href='//maps.google'>
I had this also:
<link rel='dns-prefetch' href='//s.w'>
But, I removed it with this code inside my functions.php
add_filter( 'emoji_svg_url', '__return_false' );
Probably, this is added by one plugin exifografy, which can show map of location where image is taken. But, there is just few posts with map, so having this on all URL-s is just one more line of not used HTML code.
Share Improve this question asked Aug 22, 2016 at 16:22 Advanced SEOAdvanced SEO 6892 gold badges16 silver badges41 bronze badges3 Answers
Reset to default 6Resource Hints is a smart feature added to WordPress version 4.6. I think it might improve your site speed. But if you want to disable it, try this:
remove_action('wp_head', 'wp_resource_hints', 2);
References
- wp_head resource hints
- wp_resource_hints filter
/*
* Removes <link rel="prefetch" for WP assets not used in the theme
* */
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);
I would suggest to remove it only if not used in the theme, this is the helper function I'm using
I did this by using wp_resource_hints filter and preg_match :
/**
* Removes dns-prefetchs links in header
*/
public function remove_prefetchs($urls) {
foreach ($urls as $key => $url) {
if(preg_match('/google|code.jquery$/', $url) === 1) {
unset( $urls[ $key ] );
}
}
return $urls;
}
add_filter( 'wp_resource_hints', array( $this, 'remove_prefetchs' ), 10, 2);
本文标签: Remove rel39dnsprefetch39 href39mapsgooglecom39 from wphead
版权声明:本文标题:Remove rel='dns-prefetch' href='maps.google.com' from wp-head 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741644032a2390082.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论