Support » Plugin: Clearfy – WordPress optimization plugin and disable ultimate tweaker » Remove dns-prefetch – removes all dns-refetch links, not only WP links

  • Resolved ripleman


    Hi, thanks for this plugin

    I found strange behavior in “Remove dns-prefetch” option. As I understand this option should remove only WP links, like in description.

    But it removes not only WP <link rel=’dns-prefetch’ href=’//’ />,
    but ALL other ‘dns-prefetch’, even my custom links, like ‘//’.

Viewing 5 replies - 1 through 5 (of 5 total)
  • Hello @ripleman. Thanks for your issue! It really helps to make Clearfy better.

    Indeed, remove is not a good idea. It’s slow down Google Fonts loading. In the nearest update we’ll fix it.

    By default we’ll remove all of dns-prefetch records. However, we’ll add the field with domains exclusions wich needs to prefetch and the will be present by default in it. What do you think about such solution?

    In my opinion, to remove ALL dns-prefetch links in WP Code Cleaning settings + filter some Google links, is not suitable for all users, because you dont know for sure what links they can add.
    WP adds by default only <link rel=’dns-prefetch’ href=’//’ />. Other links are added by themes/plugins/users. So in WP Code Cleaning option it is logically to remove only ‘//’. Like in this snippet: add_filter( 'emoji_svg_url', '__return_false' );

    And, for example, in Advanced Code Cleaning section you can make option to clean ALL dns-prefetch links and left field for users to manually add links they want. Or make there predefined links like ‘//’ ‘//’ ‘//’ as hint or manual option for user. But maybe this functional is superfluous, because caching plugins can handle it. For example WP Rocket have option to add custom dns-prefetch links.

    @ripleman, thanks for your answer and opinion! We’ll fix the problem and think about advanced dns-prefetch options.

    Have a nice day!

    You remove wp_resource_hints in your plugin with this hook:

    if( $this->getOption('remove_dns_prefetch') ) {
    	remove_action('wp_head', 'wp_resource_hints', 2);

    WP adds by default with this function <link rel=’dns-prefetch’ href=’//’ /> and <link rel='dns-prefetch' href='//' />

    So all this links will be removed and all links added with wp_resource_hints will not work.

    But there is one important thing related to “dns-prefetch”:
    On HTTPS web site by default “dns-prefetch” will not work, so we need to add <meta http-equiv="x-dns-prefetch-control" content="on"> meta tag to to enable “x-dns-prefetch-control”, WP dont do this by default, and wp_resource_hints cant add this meta tag.

    You can remove wp_resource_hints and make your own function to add links to header.

    So I think it will be very useful to add custom links to header and user can define there own domains with custom links and priority (output order).
    And even with ability to add or exclude links for different pages. Because ‘contacts’ page will have more links to google maps, for example.

    And now we have more resources hints, which are very useful to speed up site loading. And I think it will be very convenient to add them with UI:
    1) “dns-prefetch” with <meta http-equiv="x-dns-prefetch-control" content="on"> added by default.
    2) “preconnect” – better “dns-prefetch”, but for modern browsers
    3) “prefetch”
    4) “preload”
    5) “prerender”

    But maybe it is simple to do with another plugins, which add links to head, and not related to this plugin. But one of cant add links to individual pages, another cant set links output priority in header, another dont clean DB on uninstall, another have ads or need pro version, or have errors and etc.

    [ Please do not bump. ]

    Thanks for your help @ripleman!
    We temporary remove dns prefetch feature for not harm users’ websites performance. In future updates we’ll turn it back and modernize.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Remove dns-prefetch – removes all dns-refetch links, not only WP links’ is closed to new replies.