DEV Community

Cover image for Remove S.W.org DNS prefetch from Wordpress
SeanAUS120
SeanAUS120

Posted on

Remove S.W.org DNS prefetch from Wordpress

Making Wordpress faster is an ongoing experiment. There's a few more things I've discovered which can be removed for small (albeit in this case, VERY small, speed gain). DNS prefetching Google fonts and S.W.org which pulls files from the WP repository.

add_action( 'init', 'remove_dns_prefetch' );
function  remove_dns_prefetch () {
   remove_action( 'wp_head', 'wp_resource_hints', 2, 99 );
}
Enter fullscreen mode Exit fullscreen mode

It's as easy as that. We use it here and here.

Top comments (2)

Collapse
 
__d28a64f4e0e profile image
Виктор Иванов

As a one-off solution — yes, this will help. But for multiple cases, it might not cover everything. In my case, I use a ready-made tool, Clearfy Pro, set it up once and don’t have to worry about it anymore. Thanks to the author — this can definitely be useful for beginners.

Collapse
 
rboylson profile image
rboylson

Amazing! Thank you for the easy tutorial 🙌