Back to Guides
Network 10 min Updated 2026

DNS Prefetching & Preconnecting

Speed up third-party resource loading by resolving DNS lookups in advance.

DNS Prefetching & Preconnecting

Every time your site loads a resource from a third party (like Google Fonts, Analytics, or a Facebook pixel), the browser has to perform a DNS lookup to find the server's IP address. This takes time (20-100ms).

DNS Prefetching tells the browser: "Hey, we're going to need this domain soon, so look it up now."

The Difference: Prefetch vs. Preconnect

  • DNS Prefetch: "Resolve the domain name to an IP." (Low cost)
  • Preconnect: "Resolve the domain AND establish the TCP handshake." (Higher cost, but faster for resources you definitely need immediately).

Step 1: Identifying Domains

First, find out what external domains your site is calling.

  1. Open your site in Chrome.
  2. Open DevTools (F12) > Network.
  3. Reload.
  4. Filter by "JS", "CSS", "Font".
  5. Look for domains that aren't yours (e.g., fonts.googleapis.com, connect.facebook.net).

Step 2: Implementing with WP Rocket

  1. Go to Settings > WP Rocket > Preload.
  2. Scroll to Prefetch DNS Requests.
  3. Paste the URLs of the domains you found (one per line).

Common URLs to Prefetch:

//fonts.googleapis.com
//fonts.gstatic.com
//www.google-analytics.com
//connect.facebook.net
//maps.googleapis.com

Step 3: Manual Implementation (Header)

If you don't use a plugin, add this to your <head> section (via header.php or a snippet plugin):

[object Object],
,[object Object],

For critical assets (like Google Fonts), use Preconnect:

[object Object],

Conclusion

DNS Prefetching is a micro-optimization, but these milliseconds add up. It makes your site feel snappier, especially on mobile networks with high latency.

Next, we will look at Heartbeat API Control, stopping your server from hyperventilating.