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:
Here are a few other third-party domains you can prefetch:
WP Rocket, Perfmatters, Pre* Party Resources Hints, 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.
DNS Prefetch In WP Rocket – in WP Rocket, prefetch DNS requests is in the Preload tab.
DNS Prefetch In Perfmatters – in Perfmatters, prefetch DNS requests is in Extras > Preloading.
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.
//maps.googleapis.com //maps.gstatic.com //fonts.googleapis.com //fonts.gstatic.com //ajax.googleapis.com //apis.google.com //google-analytics.com //www.google-analytics.com //ssl.google-analytics.com //youtube.com //api.pinterest.com //cdnjs.cloudflare.com //domain.kinstacdn.com //pixel.wp.com //connect.facebook.net //platform.twitter.com //syndication.twitter.com //platform.instagram.com //disqus.com //sitename.disqus.com //s7.addthis.com //platform.linkedin.com //w.sharethis.com //s0.wp.com //s1.wp.com //s2.wp.com //s.gravatar.com //0.gravatar.com //2.gravatar.com //1.gravatar.com //stats.wp.com //www.googletagmanager.com //www.googletagservices.com //adservice.google.com //pagead2.googlesyndication.com //tpc.googlesyndication.com //securepubads.g.doubleclick.net //bp.blogspot.com //1.bp.blogspot.com //2.bp.blogspot.com //3.bp.blogspot.com //4.bp.blogspot.com //ajax.microsoft.com //ajax.aspnetcdn.com //s3.amazonaws.com //a.opmnstr.com //script.hotjar.com //i.ytimg.com //code.jquery.com //stackpath.bootstrapcdn.com //use.fontawesome.com //player.vimeo.com //github.githubassets.com //referrer.disqus.com //c.disquscdn.com //0.gravatar.com //2.gravatar.com //1.gravatar.com //ad.doubleclick.net //googleads.g.doubleclick.net //stats.g.doubleclick.net //cm.g.doubleclick.net //stats.buysellads.com //s3.buysellads.com
Don’t forget to preload key requests and preconnect to required origins!
Keep reading the article at Tom Dupuis. The article was originally written by Tom Dupuis on 2021-03-30 18:25:44.
The article was hand-picked and curated for you by the Editorial Team of WP Archives.