[How To] Remove DNS-Prefetch WordPress
What is DNS-Prefetch ?
DNS prefetching is an attempt to resolve domain names before a user tries to follow a link. This is done using the computer’s normal DNS resolution mechanism.
The main reason for rel=dns-prefetch to exist is to speed up the way web pages load when they are using different domains for page resources. This process is often called “DNS prefetching“.
The WordPress link looks like this:
<link rel='dns-prefetch' href='//s.w.org' />
Remove DNS-Prefetch from WordPress site
To remove the DNS-Prefetch link from WordPress wp_head hook is not very hard.
You can add the following code to your functions.php to remove DNS-Prefetch link from your header:
add_action( 'init', 'remove_dns_prefetch' ); function remove_dns_prefetch () { remove_action( 'wp_head', 'wp_resource_hints', 2, 99 ); }
2 Comments
Hy “Error: Bad value x-dns-prefetch-control for attribute http-equiv on element meta.
From line 1, column 138; to line 1, column 192
xfn/11″/> <link"
Help
Did you add this lines in the function.php file from your theme?
add_action( ‘init’, ‘remove_dns_prefetch’ );
function remove_dns_prefetch () {
remove_action( ‘wp_head’, ‘wp_resource_hints’, 2, 99 );
}