STAGING
  1. Home
  2. Knowledge Base
  3. Onboarding, Site Setup & Speed Optimization
  4. Third-Party Scripts and Preconnect: What Your Host Can and Cannot Fix

Third-Party Scripts and Preconnect: What Your Host Can and Cannot Fix

When a speed test shows a slow page, the natural assumption is that the server is slow. Often the slowest files on the page do not come from the server at all. Analytics, tag managers, ad pixels, chat widgets and opt-in tools load from their providers’ own servers, and nothing on our side changes how fast those respond. What you can change is when the browser starts connecting to them. This article explains how to tell server time from third-party time in a speed test, and how to use the preconnect directive on a site hosted with us.

Your files versus everyone else’s

Files that belong to your site (images, CSS and JavaScript from your theme and plugins) are served by our server, or from Cloudflare’s cache if your domain uses it. In a waterfall they usually finish in tens of milliseconds.

Third-party files come from the provider’s infrastructure. In the example in the video, an Australian site tested from Australia, a marketing automation script took 824 ms and a click fraud protection script took 856 ms. Most of that time was spent on the DNS lookup, connecting and negotiating SSL, before a single byte of the file downloaded.

Distance accounts for much of it. Many of these services are hosted in the United States, so a visitor in Australia or the UK makes a long round trip for each new connection. That is true whichever host or data centre your site is on.

Reading the waterfall

  • Run a test that shows a waterfall view. The video uses SiteSpeedBot; GTmetrix and WebPageTest show the same kind of chart.
  • Look at the first row, the HTML document. Its waiting time is the server producing the page. If that is consistently slow, it is a hosting or WordPress question and worth a ticket.
  • Look for wide bars from other domains and hover over them for the breakdown. Long DNS, connect and SSL segments are what preconnect helps with. A long download segment is the size of the file, which preconnect does not change.

What preconnect does

It is a single line in the head of the page:

<link rel="preconnect" href="https://www.googletagmanager.com">

When the browser reads it, it does the DNS, connection and SSL work for that host immediately, rather than when it reaches the script later in the page. The provider’s server is no faster; the setup simply overlaps with the rest of the load. The video shows the result: in the waterfall, the bar for a preconnected host splits in two, with the connection made early and the file downloaded later.

Adding preconnects on a WP Alpha site

You do not need server access or theme edits. Use whichever optimisation plugin you already run:

  • Autoptimize: Settings, Autoptimize, Extra tab, “Preconnect to 3rd party domains”. Enter full host names including https://.
  • Perfmatters: the preconnect option in its preloading settings.
  • By hand: a header snippet plugin or a child theme, using the line above.

Save, then clear the page cache: your plugin’s purge button, and the server cache from the hosting panel if you use it. The hints live in the cached HTML, so nothing changes until the cache refreshes.

Typical hosts worth adding are Google Tag Manager, Google Analytics, the Facebook pixel, Google Fonts, YouTube if videos appear on most pages, reCAPTCHA (served from www.google.com) and any opt-in or chat tool. Keep the list to hosts that load on most pages and that show slow setup times in the waterfall.

What will not fix third-party delays

  • A bigger hosting plan. More server resources speed up the first row of the waterfall, not the third party’s rows.
  • Page caching. A cached page still loads exactly the same external scripts.
  • Preconnecting to everything. Each hint opens a connection, and connections that are never used are wasted effort for the browser during the busiest part of the load.

When to open a ticket

Open a ticket from the client area if the HTML document row is consistently slow, if you have added preconnects but they do not appear in the page source after clearing every cache, or if you are not sure which slow files belong to the site and which to third parties. Include:

  • The URL you tested.
  • A link to the speed test result or a screenshot of the waterfall.
  • The location the test was run from.
  • The optimisation and caching plugins active on the site.

Our support team can confirm how quickly the server is responding, check that caching is working, and point out which entries in the waterfall sit outside the hosting.

Related Articles

Need Support?

Can't find the answer you're looking for? Log a request by clicking the button below or try the livechat in the bottom right hand corner
Contact Support