Last Updated on 2 weeks by Selen Cetin
Third-party codes—ads, analytics tools, social network integrations—can be quite important for giving your website more capability. Still, it usually results in a poor performance. Page Speed Insights’ “Reduce the impact of third-party code” warning shows that outside scripts are slowing down your site and compromising user experience. Here’s how to minimise their effect.
Why Does Third-Party Code Affect Performance?
Load times, block rendering, and your page’s Time to Interactive (TTI) could all be affected by third-party scripts loaded from outside sources. Additionally vying for main-thread execution are these scripts, which reduces the responsiveness of your site to user interactions.
How to Reduce the Impact of Third-Party Code:
- Limit the Use of Third-Party Scripts: Use outside services specifically needed for your site only. Every external script increases the load time, hence it is important to routinely check and eliminate any pointless services.
- Defer or Async JavaScript Loading: Third-party scripts should be used using the async or defer characteristics to guarantee they won impede critical rendering. This runs non-essential scripts following the loading of the primary content, therefore accelerating your page.
- Lazy Load Third-Party Content: Load third-party materials—ads or social widgets—delayed until they are really needed. Your site’s apparent load speed and performance will be much enhanced by this approach.
- Optimize Third-Party Script Execution: Find slow outside scripts using Lighthouse or GTmetrix. If a third-party service is overly slow, think about utilising an optimised substitute or working with the service provider to fix performance problems.
- Use a Content Delivery Network (CDN): Make sure the quick, efficient CDNs used by outside services you depend on match. This can lower load times and aid to cut the latency of outside resources.
Although outside code can improve the functionality of your website, efficiency is usually sacrificed. Reducing needless scripts, postponing non-critical loading, and managing third-party resource handling will help to lower their negative influence and increase the speed and usability of your website.
For more details, check out the Chrome Developer Guide.