Title: Remove the new dns-prefetch code
Last modified: September 1, 2016

---

# Remove the new dns-prefetch code

 *  [olorin](https://wordpress.org/support/users/olorin/)
 * (@olorin)
 * [9 years, 9 months ago](https://wordpress.org/support/topic/remove-the-new-dns-prefetch-code/)
 * Hello,
 * How can I remove the new dns-prefecth code added to my website since the new 
   update ?
 *     ```
       <link rel='dns-prefetch' href='//fonts.googleapis.com'>
       <link rel='dns-prefetch' href='//s.w.org'>
       ```
   
 * Thanks

Viewing 15 replies - 1 through 15 (of 23 total)

1 [2](https://wordpress.org/support/topic/remove-the-new-dns-prefetch-code/page/2/?output_format=md)
[→](https://wordpress.org/support/topic/remove-the-new-dns-prefetch-code/page/2/?output_format=md)

 *  [Tim Bowen](https://wordpress.org/support/users/creativeslice/)
 * (@creativeslice)
 * [9 years, 9 months ago](https://wordpress.org/support/topic/remove-the-new-dns-prefetch-code/#post-7678189)
 * I’m also trying to remove this and tried to remove the filter like this:
 * `remove_action( 'wp_head', 'dns-prefetch' );`
 * It didn’t work though. Please let me know if you find a solution.
 * It looks like this is a known bug:
    [https://core.trac.wordpress.org/ticket/37694](https://core.trac.wordpress.org/ticket/37694)
 *  [Jacob Peattie](https://wordpress.org/support/users/jakept/)
 * (@jakept)
 * [9 years, 9 months ago](https://wordpress.org/support/topic/remove-the-new-dns-prefetch-code/#post-7678191)
 *     ```
       remove_action( 'wp_head', 'wp_resource_hints', 2 );
       ```
   
 * But can I ask why? It’s there to improve the performance of your site.
 *  [Tim Bowen](https://wordpress.org/support/users/creativeslice/)
 * (@creativeslice)
 * [9 years, 9 months ago](https://wordpress.org/support/topic/remove-the-new-dns-prefetch-code/#post-7678194)
 * Thank you Jacob, that worked perfect.
 * I’m fine using dns-prefetch for asset related URL’s, but it seems like the`s.
   w.org` link is unnecessary since it’s not related to any JS or CSS on the website.
 *  [Jacob Peattie](https://wordpress.org/support/users/jakept/)
 * (@jakept)
 * [9 years, 9 months ago](https://wordpress.org/support/topic/remove-the-new-dns-prefetch-code/#post-7678196)
 * I believe that’s for emoji. It can be removed separately:
 *     ```
       add_filter( 'emoji_svg_url', '__return_false' );
       ```
   
 * There’s also another filter, [`wp_resource_hints`](https://developer.wordpress.org/reference/hooks/wp_resource_hints/),
   that can be used to filter out/add specific URLs.
 *  [Tim Bowen](https://wordpress.org/support/users/creativeslice/)
 * (@creativeslice)
 * [9 years, 9 months ago](https://wordpress.org/support/topic/remove-the-new-dns-prefetch-code/#post-7678200)
 * Thank you Jacob, we’re already using this to remove emoji:
 *     ```
       // Remove emoji script
       remove_action( 'wp_head', 'print_emoji_detection_script', 7 );
       remove_action( 'wp_print_styles', 'print_emoji_styles' );
       ```
   
 * And the additional of your code helps remove this extra dns-prefetch:
 *     ```
       add_filter( 'emoji_svg_url', '__return_false' );
       ```
   
 * Thank you!
 *  Thread Starter [olorin](https://wordpress.org/support/users/olorin/)
 * (@olorin)
 * [9 years, 9 months ago](https://wordpress.org/support/topic/remove-the-new-dns-prefetch-code/#post-7678201)
 * Thanks Jacob !
 * > But can I ask why? It’s there to improve the performance of your site.
 * Sure, I don’t use googlefonts or emoji on my website.
 *  [Jacob Peattie](https://wordpress.org/support/users/jakept/)
 * (@jakept)
 * [9 years, 9 months ago](https://wordpress.org/support/topic/remove-the-new-dns-prefetch-code/#post-7678205)
 * The only URL that WordPress seems to add in itself is the emoji one. The rest
   are pulled from `wp_enqueue_style()` and `wp_enqueue_script()`. It looks like
   a plugin or theme you’re using is loading a Google font.
 *  [neotrope](https://wordpress.org/support/users/neotrope/)
 * (@neotrope)
 * [9 years, 9 months ago](https://wordpress.org/support/topic/remove-the-new-dns-prefetch-code/#post-7678342)
 * Does anyone know if using this will adversely impact other DNS prefetching which
   we do with mod_pagespeed ?
 * We don’t use emoji or google fonts so want to also remove the
    `<link rel='dns-
   prefetch' href='//s.w.org'>`
 * Will this ONLY solution only remove that single element?
    `remove_action( 'wp_head','
   wp_resource_hints', 2 );`
 * thanks 🙂
 *  [Ramanan](https://wordpress.org/support/users/superpoincare/)
 * (@superpoincare)
 * [9 years, 9 months ago](https://wordpress.org/support/topic/remove-the-new-dns-prefetch-code/#post-7678368)
 * You can do it using the code here:
 * [https://core.trac.wordpress.org/ticket/37694](https://core.trac.wordpress.org/ticket/37694)
 * That is:
 *     ```
       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 );
       ```
   
 *  [neotrope](https://wordpress.org/support/users/neotrope/)
 * (@neotrope)
 * [9 years, 9 months ago](https://wordpress.org/support/topic/remove-the-new-dns-prefetch-code/#post-7678384)
 * Okay, just as FYI, both solutions “work” – but we are using the latter ( thanks
   [@ramanan](https://wordpress.org/support/users/ramanan/)).
 * This works:
    `remove_action( 'wp_head', 'wp_resource_hints', 2 );`
 * this also works, but seems way more specific, which is gooder! 🙂
 *     ```
       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 );
       ```
   
 * Since this is specific to WordPress, should not impact external pre-fetch injections
   from mod_pagespeed, which we have off for upgrading at the moment so can’t test
   my original worry on the first example code.
 * 🙂
 * WordPress really should have a toggle in the general setting “Use emojis” yes/
   no. For a blog about candy, sure. For a pure business news portal, not really
   needed.
 *  [clarancedias](https://wordpress.org/support/users/clarancedias/)
 * (@clarancedias)
 * [9 years, 9 months ago](https://wordpress.org/support/topic/remove-the-new-dns-prefetch-code/#post-8176476)
 * none works for me, is there any other solution. please give if any.
 *  [digital_muse](https://wordpress.org/support/users/digital_muse/)
 * (@digital_muse)
 * [9 years, 8 months ago](https://wordpress.org/support/topic/remove-the-new-dns-prefetch-code/#post-8204717)
 * I ran W3C’s Link Checker and it keeps giving me an error on the dns-prefetch 
   line for google fonts api:
 * [http://fonts.googleapis.com](http://fonts.googleapis.com) is 404 Not Found
 * Am trying to understand the issue – does that mean the prefetch isn’t working?
   Or is W3C Validator checking the wrong thing?
 * Thanks!
    Abby
 *  [robwent](https://wordpress.org/support/users/robwent/)
 * (@robwent)
 * [9 years, 7 months ago](https://wordpress.org/support/topic/remove-the-new-dns-prefetch-code/#post-8304517)
 * [@abbey](https://wordpress.org/support/users/abbey/) the prefetch is just to 
   find the ip address of the server where the resources are hosted. It doesn’t 
   actually retrieve any files.
 * If a site has a lot of assets then the browser can lookup the ip address of external
   hosts whilst downloading other assets, and then when it comes to downloading 
   the ones from that host, it doesn’t need to perform a dns lookup as it already
   knows the location and can directly request the needed assets.
 *  [suzbwise](https://wordpress.org/support/users/suzbwise/)
 * (@suzbwise)
 * [9 years, 6 months ago](https://wordpress.org/support/topic/remove-the-new-dns-prefetch-code/#post-8489014)
 * The prefetch would be fine, as ‘robwent’ mentioned – just the address of the 
   server – but it has been throwing 404 errors. Try the URL – Google cannot find
   the requested URL on the server 🙁 oh no! Now what?
 *  [robwent](https://wordpress.org/support/users/robwent/)
 * (@robwent)
 * [9 years, 6 months ago](https://wordpress.org/support/topic/remove-the-new-dns-prefetch-code/#post-8490545)
 * A 404 is irrelevant.
    You are missing the point of what this is for. Google doesn’t
   go to the URL in the prefetch link and get a 404 page. It looks up the IP of 
   the domains server so that when it needs a resourse from that domain its faster
   to get it as the DNS location has already been found.

Viewing 15 replies - 1 through 15 (of 23 total)

1 [2](https://wordpress.org/support/topic/remove-the-new-dns-prefetch-code/page/2/?output_format=md)
[→](https://wordpress.org/support/topic/remove-the-new-dns-prefetch-code/page/2/?output_format=md)

The topic ‘Remove the new dns-prefetch code’ is closed to new replies.

## Tags

 * [fail](https://wordpress.org/support/topic-tag/fail/)
 * [header](https://wordpress.org/support/topic-tag/header/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 23 replies
 * 14 participants
 * Last reply from: [masouds](https://wordpress.org/support/users/masouds/)
 * Last activity: [9 years, 1 month ago](https://wordpress.org/support/topic/remove-the-new-dns-prefetch-code/page/2/#post-9109891)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
