How To Add DNS Prefetch In WordPress (For Third-Party Domains)

DNS prefetch is an easy way to make your WordPress site faster by establishing an early connection to third-party domains.

To add DNS prefetch to WordPress, add this code to your header:

dns-prefetch" href="https://example.com">

Here are a few other third-party domains you can prefetch:

dns-prefetch" href="https://cdn.domain.com">
dns-prefetch" href="https://fonts.gstatic.com">
dns-prefetch" href="https://connect.facebook.net">
dns-prefetch" href="https://www.google-analytics.com">
dns-prefetch" href="https://www.googletagservices.com">

WP Rocket, Perfmatters, Pre* Party Resources Hints, SG Optimizer, LiteSpeed Cache, and most cache plugins have an option to prefetch DNS requests.

View your PageSpeed Insights or GTmetrix report and view which third-party domains are loaded on your site. Once you find these, copy/paste them into your list of prefetched domains.

Prefetch DNS Requests - GTmetrix Domains

Prefetch DNS Requests - PageSpeed Insights

DNS Prefetch In WP Rocket – in WP Rocket, prefetch DNS requests is in the Preload tab.

Prefetch DNS Requests in WP Rocket

DNS Prefetch In Perfmatters – in Perfmatters, prefetch DNS requests is in Extras > Preloading.

DNS Prefetch - Perfmatters

DNS Prefetch In SG Optimizer SG Optimizer lets you add DNS prefetch for external domains in the Environment Optimization settings.

DNS Prefetch - SG Optimizer

DNS Prefetch In LiteSpeed Cache – LiteSpeed Cache can add DNS prefetch to WordPress under Page Optimization > Optimizations > DNS Prefetch. They also have a DNS Prefecth Control setting where browsers will perform domain name resolution on both links that the user may choose to follow as well as URLs for items referenced by the document (CSS, JS, etc).

DNS Prefetch in LiteSpeed Cache

Complete list – for a more complete list, see Luke’s list of common domains to prefetch on Github (I added a few others). If I missed any common ones, leave me a comment and I’ll add it.

dns-prefetch" href="https://maps.googleapis.com">
dns-prefetch" href="https://maps.gstatic.com">
dns-prefetch" href="https://fonts.googleapis.com">
dns-prefetch" href="https://fonts.gstatic.com">
dns-prefetch" href="https://ajax.googleapis.com">
dns-prefetch" href="https://apis.google.com">
dns-prefetch" href="https://google-analytics.com">
dns-prefetch" href="https://www.google-analytics.com">
dns-prefetch" href="https://ssl.google-analytics.com">
dns-prefetch" href="https://youtube.com">
dns-prefetch" href="https://api.pinterest.com">
dns-prefetch" href="https://cdnjs.cloudflare.com">
dns-prefetch" href="https://domain.kinstacdn.com">
dns-prefetch" href="https://pixel.wp.com">
dns-prefetch" href="https://connect.facebook.net">
dns-prefetch" href="https://platform.twitter.com">
dns-prefetch" href="https://syndication.twitter.com">
dns-prefetch" href="https://platform.instagram.com">
dns-prefetch" href="https://disqus.com">
dns-prefetch" href="https://sitename.disqus.com">
dns-prefetch" href="https://s7.addthis.com">
dns-prefetch" href="https://platform.linkedin.com">
dns-prefetch" href="https://w.sharethis.com">
dns-prefetch" href="https://s1.wp.com">
dns-prefetch" href="https://1.gravatar.com">
dns-prefetch" href="https://s.gravatar.com">
dns-prefetch" href="https://stats.wp.com">
dns-prefetch" href="https://www.googletagmanager.com">
dns-prefetch" href="https://www.googletagservices.com">
dns-prefetch" href="https://adservice.google.com">
dns-prefetch" href="https://pagead2.googlesyndication.com">
dns-prefetch" href="https://tpc.googlesyndication.com">
dns-prefetch" href="https://securepubads.g.doubleclick.net">
dns-prefetch" href="https://bp.blogspot.com">
dns-prefetch" href="https://1.bp.blogspot.com">
dns-prefetch" href="https://ajax.microsoft.com">
dns-prefetch" href="https://ajax.aspnetcdn.com">
dns-prefetch" href="https://s3.amazonaws.com">
dns-prefetch" href="https://a.opmnstr.com">
dns-prefetch" href="https://script.hotjar.com">
dns-prefetch" href="https://i.ytimg.com">
dns-prefetch" href="https://code.jquery.com">
dns-prefetch" href="https://stackpath.bootstrapcdn.com">
dns-prefetch" href="https://use.fontawesome.com">
dns-prefetch" href="https://player.vimeo.com">
dns-prefetch" href="https://github.githubassets.com">
dns-prefetch" href="https://referrer.disqus.com">
dns-prefetch" href="https://c.disquscdn.com">
dns-prefetch" href="https://ad.doubleclick.net">
dns-prefetch" href="https://googleads.g.doubleclick.net">
dns-prefetch" href="https://stats.g.doubleclick.net">
dns-prefetch" href="https://cm.g.doubleclick.net">
dns-prefetch" href="https://stats.buysellads.com">
dns-prefetch" href="https://s3.buysellads.com">

Don’t forget to preload key requests and preconnect to required origins!

If you have any questions or want to add another domain to my list of common domains to prefetch for WordPress, drop me a comment.

Cheers,
Tom

About Tom Dupuis

Tom Dupuis 2017Tom Dupuis writes WordPress speed and SEO tutorials out of his apartment in Denver, Colorado. In his spare time, he plays Rocket League and watches murder documentaries. Read his bio to learn 50 random and disturbing things about him.

Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments