Should you DNS-Prefetch all 3rd Party Domains?

What the heck is DNS-Prefetching anyways?

DNS-Prefetching is how you resolve Domain Names before the resources are requested. Resolving domain names here means resolving a website’s IP address.

What happens if you don’t do this?

If you don’t leverage DNS-Prefetching then that can add several extra seconds for the resource to load & that can severely impact the core web vitals performance.

How to identify 3rd Party Domains being used by the page?

Several tools can help with this.

1. Chrome DevTools can reveal what all 3rd party domains are being used by the page.

chrome devtools 3rd party domains

2. GTmetrix

3. WebPageTest

These are the 3 tools that will reveal the 3rd party domains that the page is utilizing for loading resources on the page.

How to identify the DNS Lookup time it takes currently?

The same 3 tools will reveal the DNS Lookup time that is being consumed currently.

Here is an example of how you can identify that from Chrome DevTools

Coming back to the main goal of this post, should you DNS-Prefetch all 3rd party domains?

The answer is no, even if you Google it you will find various resources stating that you shouldn’t. The reason is quite simple.

If in the first load x number of 3rd party domains aren’t going to get requested then DNS-Prefetching them will instead increase the time defeating the purpose of why we are doing this.

But.. I wanted to test this & that’s precisely what I did. And results seem conclusive that you shouldn’t DNS-Prefetch all 3rd Party Domains.

But don’t take my word for it, have a look at these screenshots that represents the source of truth.

DNS Prefetch Experiment

As you can see in the screenshot above, the DNS Lookup time drastically reduced when I started Prefetching only those domains that were being used in the first load instead of DNS-Prefetching all the 3rd party domains that the page utilizes.

But wait a minute How did I identify 3rd party domains being used in the first load?

I scanned the page on WebPageTest where it shows a waterfall chart for 1st Run, 2nd Run & So on.

From those Waterfall chart you can identify those 3rd party domains and select those for which DNS Lookup is taking place.

Leave a Comment