Ads, analytics, and social widgets can seriously hurt the performance of your site. If you have dozens (or more!) third parties on a page, it can be tricky to figure out which one is the source of your pain.
Image: Freepik
In this article, we'll explain how to:
Some interesting (and scary) facts about third-party scripts:
Many — if not most — sites and apps rely on third-party scripts. For example, if you want to do user tracking, you might have separate scripts for:
All of those third-party tags are inserted on any given page in one fell swoop courtesy of tag managers (such as Google Tag Manager), which allow you to deploy and run scripts without having to go through the pain of re-deploying the entire site.
As a result, adding and executing scripts is a fairly trivial task. It is so effortless, in fact, that even non-developers on your team can contribute their own fair share of scripts, often without any form of performance analysis. The boss wants something, and it’s going to happen one way or another, and GTM facilitates that work without friction between teams.
If you're not certain how many third-party scripts are on your site, you're not alone. As scripts accumulate, obsolete scripts are often left behind. The first thing you need to do is run synthetic tests on the key pages on your site. From your test, you should be able to generate a list of third parties for each page, like this:
Some things to note:
It's important to know how every script is implemented on your pages. Broadly speaking, implementation falls into three categories:
Blocking – Just it sounds, a blocking script needs to be fully rendered before the rest of the page will render. A slow blocking script will slow down your page. A non-functioning blocking script – for example, caused by an outage with the third-party provider – will prevent the page from rendering at all.
Aynchronous – With asynchronous rendering, third-party scripts load in parallel with crucial page content. This lets you display ads and other business-critical third-party scripts without blocking your primary content.
An easy way to see the impact of third parties on your pages' loading times: run synthetic tests of the page, with and without third parties enabled.
SpeedCurve's built-in script lets you block third parties for a page. You can block all scripts, or select specific third parties.
After testing the page above with and without third parties, the results are quite stark:
With third parties enabled, the Largest Contentful Paint time for this page is 26.82 seconds. Without any third parties, LCP is under 1 second.
It's important to state that the solution is not to remove all the third party scripts from the page. The slowdown might be caused by just one or two bad actors. The next step would be to run more synthetic tests that block individual scripts until you determine which ones are problematic.
As mentioned above, when monitoring and analyzing third party performance, you should investigate:
Time series chart show blocking scripts, Long Tasks time, and number of Long Tasks
While you don't have much control over the actual third-party script, you can still track each script over time and get alerts when any of the performance metrics you're tracking suffer. Performance budgets let you:
A performance budget for a third-party script (Amazon Ads), with a budget threshold of 50ms, showing when the script has become a Long Task – and could be slowing down the page.
You don’t need to passively accept poor third-party behaviour. Yes, third parties are tricky because you don’t have complete control over them. But you do have more control than you might think. For example, you can monitor how they affect your pages over time and use that data to negotiate SLAs with your third-party providers.
Who are they? What’s their performance track record? What is their average monthly downtime? What’s their response time and time to last byte when tested from key locations? Do they use a CDN, and if so, where are their caches located? The vendor should be able to give you clear answers to these questions.
Most third-party providers don’t offer real-time monitoring of their scripts, nor do they offer meaningful service level agreements (SLAs). This won’t change until site owners start demanding these tools.
In an ideal world, a third-party SLA would:
Whether or not the provider has an SLA may not be a deal breaker for you... yet. If the value of the script outweighs the nebulousness of not having an SLA, then you may opt to proceed and accept the fact that you’ll need to take care of your own real-time performance monitoring.
Nobody likes to be the naysayer who turns down exciting new tools, but if a tool has the potential to seriously hamper overall performance, someone has to put their foot down.
In simplest terms, deferral is a front-end optimization technique that delays the execution of non-critical scripts until the rest of the page has loaded and rendered on the browser. An advantage of deferral is that it’s a relatively easy fix; however, it won’t work for all third-party content. If your site hosts third-party ads, then your ad providers may not approve of this technique. Save deferral for third-party scripts like analytics beacons, tracking pixels, and social widgets.
With asynchronous loading, third-party scripts load in parallel with crucial page content. This lets you display ads and other business-critical third-party scripts without blocking your primary content.