Identify slow third-party JavaScript

Supercharge your performance detective skills with Lighthouse and Chrome DevTools.

Milica Mihajlija
Milica Mihajlija

As a developer, you often don't have control over which third-party scripts your site loads. Before you can optimize third-party content you have to do some detective work to find out what's making your site slow. 🕵️

In this post, you'll learn how to use Lighthouse and Chrome DevTools to identify slow third-party resources. The post walks through increasingly robust techniques which are best used in combination.

If you only have 5 minutes

The Lighthouse Performance audit helps you discover opportunities to speed up page loads. Slow third-party scripts are likely to appear in the Diagnostics section under the Reduce JavaScript execution time and Avoid enormous network payloads audits.

To run an audit:

  1. Press `Control+Shift+J` (or `Command+Option+J` on Mac) to open DevTools.
  2. Click the Lighthouse tab.
  3. Click Mobile.
  4. Select the Performance checkbox. (You can clear the rest of the checkboxes in the Audits section.)
  5. Click Simulated Fast 3G, 4x CPU Slowdown.
  6. Select the Clear Storage checkbox.
  7. Click Run audits.