ecomhint

Third-Party Scripts

Third-party scripts are external JavaScript files loaded from other domains, such as analytics, ads, chat widgets, and social media buttons.

Performance
Also known as:External Scripts, Third Party Code, External JavaScript

Third-party scripts are JavaScript files hosted on external domains that add functionality to your website. Common examples include analytics trackers, advertising pixels, live chat widgets, tools, and social media embeds. According to HTTP Archive data, the median website loads 20 external scripts totaling around 449 KB.

Impact on Performance

Third-party scripts often block the main thread, preventing the browser from rendering content or responding to user input. Lighthouse flags pages where third-party code blocks the main thread for 250 milliseconds or longer.

These scripts affect all . They can delay LCP by slowing down resource downloads or by being the LCP element themselves. They hurt INP by blocking the main thread during user interactions. Script injection can also cause layout shifts that increase .

Loading Strategies

Async and defer attributes: The async attribute downloads the script while parsing continues, then pauses parsing to execute. The defer attribute downloads during parsing but waits until parsing completes to execute. Both prevent render blocking.

: Load scripts only when needed, such as loading a chat widget when users scroll near the footer or click a button.

Web Workers: Libraries like Partytown move third-party scripts off the main thread entirely, freeing it for rendering and interactions.

Measuring Third-Party Impact

Chrome DevTools Network panel shows all external requests and their timing. The Coverage tab reveals how much loaded code actually executes. Request blocking lets you measure page performance with specific scripts disabled, helping identify the worst offenders.

1350+ stores audited

Ready to improve your conversion rate?

Knowing the term is one thing. A free audit tells you whether your own store gets it right.

Free preview  •  No credit card  •  Nothing to install