Skip to main content

Learn/Bricks Basics

The Scripts You Did Not Write Are Slowing Your Site

The heavy ones are the chat widget, the video embed and the map, not analytics. How to find them in two minutes and load them only when someone asks.

Daniel, founder of BricksfusionBy DanielSeptember 9, 20269 min read

The short answer

The heavy ones are almost never analytics. They are the chat widget, the video embed and the map, each of which loads an entire application before anyone uses it. Find them in your browser's network tab by sorting on domain, delete what you do not need, and for what you do keep, load it when someone asks for it rather than on arrival. That one change usually keeps every feature and removes most of the cost.

This is the fourth and last item on our page speed checklist, after hosting, images and fonts. It is also the one where people most often optimize the wrong thing, because the obvious suspect is rarely the culprit.

What counts as a third-party script?

Anything your page fetches from a domain that is not yours. In practice that list is longer than most people expect:

  • Analytics and tag managers
  • Chat and support widgets
  • Embedded videos
  • Embedded maps
  • Advertising and conversion tracking pixels
  • Review and trust badges
  • Social feeds and share buttons
  • Cookie consent banners
  • Fonts loaded from someone else's server

Most sites carry four or five of these without having deliberately chosen more than two, because plugins bring their own along.

Why they cost more than their size suggests

Three reasons stack up, and only the first is about file size.

Every new domain is a fresh introduction. Before the browser can download a single byte from another company, it has to look up that domain, open a connection to it, and agree on encryption. That round trip happens before the useful part starts, and on a phone on a mobile network it can cost more time than the file itself.

They compete with your page for the same thread. JavaScript runs in one queue, and the browser cannot respond to a tap while it is busy executing someone else's code. This is why a page can look finished and still ignore you for a second when you touch it.

Many of them load more scripts. A tag manager exists specifically to load other things. What you approved was one small file; what actually arrives is whatever that file decided to fetch, which can change next week without anyone telling you.

How to find what you are actually loading

Two minutes, no tools to install.

Open your site in Chrome or Edge, open developer tools, and go to the network tab. Reload the page. Then find the column showing the domain each request came from and sort by it, so everything from a single third party groups together. If that column is not shown, right click the column headers and add it.

Now read three things: which domains appear that are not yours, how much each one weighs, and how long each took. You are not looking for precision. You are looking for the one or two rows that are obviously larger than everything else, because that is almost always where the problem is concentrated.

PageSpeed Insights reports the same thing in a section on third-party usage, which is easier to read and worth checking on a page you care about rather than only the homepage.

Good to know

Do this on a real page with real content, not a clean staging page, and check a phone-shaped viewport rather than only your desktop. The gap between what a script costs on your laptop and what it costs on a mid-range phone is where most of these decisions actually get made.

The three that are usually heavy

The chat widget. Frequently the single largest thing on a small business site, because it is a complete messaging application that arrives whether or not anyone opens it. On most sites a small minority of visitors ever click it, so nearly all of that cost buys nothing.

The video embed. Dropping in an embed does not add a video. It adds a player, its interface, its styling and its own analytics, all of which load before anyone presses play. If the video is below the fold, most visitors pay for it without ever seeing it.

The map. An interactive map is a mapping engine, and it loads so a visitor can drag and zoom something that, on a contact page, they usually just want to look at.

Analytics, by contrast, is usually modest and is the passenger you get the most from. Blaming it first is common and almost always wrong. Read your own numbers before removing anything.

The technique that fixes most of this

Do not load it until someone wants it.

The pattern is the same for all three offenders. You show something cheap that looks like the real thing, and you load the real thing when the visitor interacts with it:

  • Video: show the thumbnail with a play button on it. Load the player on click. The visitor sees exactly what they expected and the page never carries a player nobody used.
  • Map: show a static image of the location with a pin, linking to the full map. Most people want the address, not a map engine, and this also gives them a route on their own phone.
  • Chat: show a button styled like the widget's launcher. Load the widget when it is clicked.

The cost is a short wait for the minority who interact, at a moment when they are already committed. The saving applies to everyone else, which is nearly everyone.

This is worth doing by hand if you have to, and several performance plugins offer it as a setting. Either way it is usually the largest speed improvement available on a site that is otherwise reasonably built.

There is an awkwardness here worth naming rather than tiptoeing around. The banner you installed to handle consent is itself often one of the heavier third-party scripts on the page, and by design it appears early, over your content, before anything else can be used.

So you can end up paying twice: once for the tracking scripts, and again for the thing asking permission to run them.

The unglamorous route out is to need less consent. Every tracker you remove is one fewer thing the banner has to cover, and a site with no third-party tracking has a much simpler compliance story and a lighter page at the same time. This is the same logic as self-hosting your fonts: the privacy-respecting option and the fast option keep turning out to be the same option. Whether any of this applies to your situation is a question for someone qualified, not for us.

What to delete outright

Deferring is good. Deleting is better, and more is deletable than people assume.

Social share buttons, which almost nobody uses and which every phone already provides. Feeds embedding a social account that has not posted in a year. Analytics you installed twice through two different plugins. Tracking pixels for advertising campaigns that ended. Review badges loading a whole widget to display a number that has not changed in months.

The test is simple: when did you last look at the data this produces, or last see a visitor use this feature? If the answer is that you have not, it is not a feature, it is a passenger.

Bottom line

Open the network tab, sort by domain, and find the two rows that dwarf the rest. Delete whatever you have not used in a year. For the video, the map and the chat, show a cheap stand-in and load the real thing on click.

That is the whole job, it takes an afternoon, and it is the last of the four things that make most sites slow. With hosting sorted, images sized properly, fonts self-hosted and the scripts you did not write kept on a leash, you have covered everything that reliably matters, and you can stop buying plugins that promise a score.

FAQ

Questions about this topic

What is a third-party script?

Any code your page loads from a domain that is not yours: analytics, a chat widget, an embedded video or map, a review badge, a tracking pixel, a cookie banner. You did not write it, you cannot see it before it runs, and it can change tomorrow without telling you.

Why do embedded videos and maps slow a page down so much?

Because an embed is not a picture, it is a whole application. A video embed loads a player, its styling and its own tracking before anyone presses play, and a map embed loads the entire mapping engine before anyone drags it. Both usually cost more than everything else on the page combined, and most visitors never interact with either.

Is Google Analytics slowing my site?

Rarely, and it is the wrong thing to blame first. Analytics scripts are comparatively small and load out of the way. The heavy items are almost always the chat widget, the video embed and the map. Measure before removing anything, because analytics is usually the cheapest passenger on the page and the one you get the most from.

How do I find which scripts are slowing my site?

Open your site, open your browser's developer tools, go to the network tab and sort by the domain column. Everything that is not your own domain is a third party, and the size and time columns tell you what each one costs. PageSpeed Insights also reports third-party usage separately, which is the same information without needing to read a table.

Can I keep a chat widget without the speed penalty?

Mostly yes, by not loading it until someone wants it. Show a button that looks like the chat widget, and load the real thing when the button is clicked. Visitors who never open chat never pay for it, and the ones who do wait a moment they were going to spend anyway. The same trick works for videos and maps.

Third-Party Scripts: Find and Fix Them | Bricksfusion