Skip to content
OSULZER.AT
Code1 min read· updated July 25, 2022

Disable WordPress DNS Prefetch

WordPress themes and plugins use DNS prefetching, which sends extra requests that may matter under the GDPR. One line of code disables it in WordPress.

WordPress themes and plugins like to use DNS prefetching to reduce load times. To be precise, prefetching asks the browser to resolve an address from the respective name server in advance. Since this naturally generates a request, it could also be relevant under the GDPR. I cannot give legal advice on that, but DNS prefetching is not technically necessary. To stop WordPress from doing DNS prefetching, simply use the following snippet.

remove_action('wp_head', 'wp_resource_hints', 2);

Simply put the line of code in your own plugin or, if you really have to, in the functions.php of your child theme or in WordPress plugins such as “Snippets”.

PHP Freelancer

Prefer to have it done for you?

Customizations, plugins, and integrations - cleanly implemented, €120/h plus VAT.

See the PHP freelancer

New project?

Contact.

Tell me briefly about your project - I'll get back to you personally.

Your data is used solely to handle your inquiry. More in the privacy policy.