- Not authored by you
- Served from third-party servers
Sites use these scripts for various purposes, including:
- Social sharing buttons
- Video player embeds
- Chat services
- Advertising iframes
- Analytics and metrics scripts
- A/B testing scripts for experiments
- Helper libraries (like date formatting, animation, and functional libraries)
Third-party scripts can provide powerful functionality, but that's not the whole story. They also affect privacy, security, and page behavior—and they can be particularly problematic for performance.
Setting up connections takes time, and sending too many requests to multiple servers causes slowdowns. That time is even longer for secure connections, which may involve DNS lookups, redirects, and several round trips to the final server that handles the user's request.
Third-party scripts often add to network overhead with things such as:
- Firing additional network requests
- Pulling in unoptimized images and videos
- Insufficient HTTP caching, which forces frequent fetching of network resources
- Insufficient server compression of resources
- Multiple instances of frameworks and libraries pulled in by different third-party embeds
If a third party has server issues and fails to deliver a resource, rendering is blocked until the request times out, which can be anywhere from 10 to 80 seconds. You can test and simulate this problem with WebPageTest Single-Point-of-Failure tests.
What to do about it #
- When choosing third-party resources, favor those that send the least amount of code while still giving you the functionality you need.
- Use performance budgets for third-party content to keep their cost in check.
- Don't use the same functionality from two different vendors. You probably don't need two tag managers or two analytics platforms.
- Routinely audit and clean out redundant third-party scripts.
To learn how to audit third-party content and load it efficiently for better performance and user experience, check out the other posts in the Optimize your third-party resources section.