DEV Community

Cover image for preconnect vs dns-prefetch: Resource hints for page speed
Rajat Sinha
Rajat Sinha

Posted on

1

preconnect vs dns-prefetch: Resource hints for page speed

Using dns-prefetch prompts the browser to look up a domain's IP address ahead of time, so it’s ready when resources from that domain need to be downloaded.

Meanwhile, preconnect directs the browser to establish a connection to a given origin before any resources from that origin are requested.

By proactively connecting to important third-party domains, you can shave off 100–500 milliseconds of load time.

Although these savings might appear minor, they can meaningfully enhance the user experience.

preconnect vs dns prefetch - ThePetNest

Because dns-prefetch has slightly different browser support than preconnect, it can act as a fallback in environments where preconnect isn't yet supported.

preconnect vs dns prefetch(Page Speed) - ThePetNest

Preconnect Browser Support

Preconnect - ThePetNest

Prefetch Browser Support

Prefetch - ThePetNest

Feel free to checkout the implementation on ThePetNest

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more

Top comments (0)

AWS GenAI LIVE image

Real challenges. Real solutions. Real talk.

From technical discussions to philosophical debates, AWS and AWS Partners examine the impact and evolution of gen AI.

Learn more