Site owners often blame hosting or images for slowness, yet a look at the page source frequently reveals a dozen external scripts: analytics, ad pixels, live chat, maps, video players, social buttons. Each loads from another server and runs on the browser's main thread, so the page may appear quickly but respond slowly to taps. These are third-party scripts: written and controlled by someone else.
How external scripts hurt a page
Every new domain costs a DNS lookup plus TCP and TLS handshakes before any bytes arrive, which can add hundreds of milliseconds on mobile. The bigger cost is CPU: the JavaScript must be parsed and executed, and while it runs the main thread cannot respond to input, which Google measures as INP. You also lose control: a widget can load further scripts, grow heavier or slow down at any time, and a synchronously loaded script whose server hangs can even stall rendering.
A Tashkent furniture shop as an example
A furniture shop site, misol.uz, carried Google Analytics, Yandex Metrica, two ad pixels, a live chat widget, an office map and a YouTube video on the home page. Mobile PageSpeed Insights showed high main-thread blocking, and Lighthouse flagged "Reduce the impact of third-party code"; third-party code made up most of the JavaScript. Only one analytics tool was actually used, one pixel belonged to a long-finished campaign, and the map was only needed on the Contacts page. Removing the extras, loading chat and video on click and keeping the map on its own page left the design unchanged but made taps noticeably more responsive on phones.
Start with an inventory
For each script ask why it exists and who uses it today. In Chrome DevTools, open the Network panel and sort by domain; Lighthouse's third-party summary shows main-thread time per provider. Right-click a request and choose "Block request domain" to see instantly how the site performs without it.
- Remove unused analytics, old campaign pixels and duplicate tools.
- Defer analytics and pixels until after load.
- Load on click heavy widgets such as chat, video and maps.
- Scope maps or payment widgets to the pages that need them.
async and defer
A plain script tag blocks HTML parsing. async downloads in parallel and runs as soon as ready, which suits independent third-party scripts; defer runs after parsing in document order, which suits your own dependent scripts. Neither stops execution from occupying the main thread, so heavy widgets need more.
<!-- Blocks the page -->
<script src="https://widget.example.com/w.js"></script>
<!-- Does not block HTML parsing -->
<script src="https://widget.example.com/w.js" async></script>
<script src="/js/main.js" defer></script>
Facades for heavy widgets
Chat scripts are often the heaviest file on a page, although few visitors open chat. Show a simple button and load the real widget on first click. Some chat services expose an API call to open the widget; check their documentation. Do the same for YouTube with a thumbnail and play button, and for maps with a static image.
<button id="chat-btn" type="button">Chat</button>
<script>
document.getElementById('chat-btn').addEventListener('click', function () {
var s = document.createElement('script');
s.src = 'https://chat.example.com/widget.js';
s.async = true;
document.head.appendChild(s);
}, { once: true });
</script>
Delaying analytics and pixels
Tracking scripts show nothing to the user, so they can start after load when the browser is idle:
function loadScript(src) {
var s = document.createElement('script');
s.src = src;
s.async = true;
document.head.appendChild(s);
}
window.addEventListener('load', function () {
var later = window.requestIdleCallback || function (cb) { setTimeout(cb, 2000); };
later(function () {
loadScript('https://pixel.example.com/tag.js');
});
});
Be honest about the trade-off: delayed analytics may miss very quick bounces and pixels may miss some conversions, so agree on it with marketing. If your site asks for consent, loading pixels only after consent helps both privacy compliance and speed.
Keep Tag Manager tidy
Google Tag Manager containers accumulate stale tags. Review them quarterly and move non-critical tags from "Page View" to a later trigger such as "Window Loaded". Your own files can be served fast from local hosting, but third-party servers are outside your control, so the most reliable speed-up is often deleting a script you no longer need.