How to remove this from WP head:

<link rel='dns-prefetch' href='//maps.google.com'>

I had this also:

<link rel='dns-prefetch' href='//s.w.org'>

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.

3 Answers 3


Resource 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);


 *  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.com|code.jquery.com$/', $url) === 1) {
                unset( $urls[ $key ] );
        return $urls;
add_filter( 'wp_resource_hints', array( $this, 'remove_prefetchs' ), 10, 2);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.