How to disable DNS Prefetch in WordPress 4.6

This WordPress hosting tutorial will explain how to disable DNS Prefetch in WordPress 4.6.

Best Web Hosting

In WordPress 4.6 the DNS Prefetch was added in the Core functions. This means means that in the web site header you could see links like:

If you want to remove the links just add this code to your Theme Functions (functions.php) file:

// Disable DNS Prefetch
function disable_resource_hints( $hints, $relation_type ) {
if ( ‘dns-prefetch’ === $relation_type ) {
return array_diff( wp_dependencies_unique_hosts(), $hints );
}

return $hints;
}
add_filter( ‘wp_resource_hints’, ‘disable_resource_hints’, 10, 2 );

That is, reload your WordPress site and you will no longer see the DNS Prefetch code.