Should you preconnect to ad networks?
Preconnecting to ad networks might seems like a great idea to quickly serve ads but usually this will just slow down ad serving along with other important metrics
Should you preconnect to ad networks?
Whenever I audit a site I always look at resource hints strategies. Sometimes clients preconnect to ad networks and that is an interesting choice. The idea is pretty obvious, by preconnecting to ad networks they hope to speed up ads and therefore increase revenue.
There is a downside to this strategy. Everything that you do early on during page load takes time (in the form of use CPU cycles and network usage). That is precious time that, if used incorrectly, can slow down other, more important resources.
In this article I take a deeper look into preconnecting to ad networks.
Table of Contents!
Background: what is preconnecting
A preconnect is a hint to browsers that the user is likely to need resources from the target resource's origin, and therefore the browser can likely improve the user experience by preemptively initiating a connection to that origin
Background: How do ad networks work?
Ad networks are platforms that connect advertisers and publishers, facilitating the process of displaying advertisements on various websites, apps, or other digital platforms. They work by bringing together two key players: advertisers who want to promote their products or services and publishers who have available ad space on their platforms.
Is preconnecting to ad networks faster?
Short answer: No, in every test for every client (from 5k to 15 million daily pageviews) I have worked for Real User Metrics have shown that preconncting to ad servers only slows the the Largest Contentful Paint. In most cases freeing up resources even led to faster ad displays.
Just take a look at this real life example. The client went from 1.8 million good pages to 6.24 million good pages in just 3 months after I removed the ad preconnects!
Long answer, probably not. Ad networks usually work by loading a single script. This script may trigger the download of a few more scripts (hosted on different hosts!). Then things get complicated but basically the ad network tries to fill your ad-slots. For each ad slot it will need to download new resources (html, images, css, fonts, new scripts etc) from different servers.
So letś break it down
The problem with preconnecting in general
Preconnecting will open a connection to an external server early on during the rendering process. The goal of the preconnect is to have an already open connection to that server once files are needed. That can save valuable time but it comes at a cost.
First of all the early network connections will compete for other network resources verr early in the rendering process. At this time the most important resources like the LCP image, stylesheets and fonts have not been download yet. So it is not a great time to compete for resources!
Second we have no way of knowing if we will actually need that network connection. Maybe the script is already in the browsers cache and the open connection will not be used for that reason. In that case, even if preconnecting would have been faster, because of client side caching we are just adding a useless new connection for every repeat visit!
As a general rule it is usually best to only preconnect to the most important resource domains (like your main CDN)
Should you preconnect to the main ad script?
Preconnecting to the main ad script will only speed up ads if the ad script is for some reason not detectable by the preload scanner
If you want to prioritize your ads and for some reason you are not using a normal external script tag <script async src="https://adnetwork.ext/script.js">
and the ad script is not browser cache-able then (and ony then!) preconnecting might be a good idea! In all other cases you are better off not preconnecting.
Should you preconnect to domains that ad networks will use later on
What ad networks did I test??
Interested in finding out if this article applies to your ad network? These are all the preconnects that I have tested in the past year. If you ad network is not in the list it does not mean that you should preconnect. It just means that I haven't tested it for you. You should set up an A/B test and test what works best for you!
<link rel="preconnect" href="//securepubads.g.doubleclick.net">
<link rel="preconnect" href="//www.google.com">
<link rel="preconnect" href="//adservice.google.com">
<link rel="preconnect" href="//tpc.googlesyndication.com">
<link rel="preconnect" href="//pagead2.googlesyndication.com">
<link rel="preconnect" href="//www.gstatic.com">
<link rel="preconnect" href="https://s0.2mdn.net" />
<link rel="preconnect" href="https://googleads.g.doubleclick.net" />
<link rel="preconnect" href="https://www.googleadservices.com" />
<link rel="preconnect" href="https://dis.criteo.com" />
<link rel="preconnect" href="https://c1.adform.net" />
<link rel="preconnect" href="https://snap.licdn.com" />
<link rel="preconnect" href="https://visitor.omnitagjs.com" />
<link rel="preconnect" href="https://secure.adnxs.com" />
<link rel="preconnect" href="https://cdn.brandmetrics.com" />
<link rel="preconnect" href="https://p.adsymptotic.com" />
<link rel="preconnect" href="https://bidder.criteo.com" />
<link rel="preconnect" href="https://gum.criteo.com" />
<link rel="preconnect" href="https://sslwidget.criteo.com" />
<link rel="preconnect" href="https://static.criteo.net" />
Need your site lightning fast?
Join 500+ sites that now load faster and excel in Core Web Vitals.
- Fast on 1 or 2 sprints.
- 17+ years experience & over 500 fast sites
- Get fast and stay fast!