Find the scripts that take longest to run while your page loads

Reduce JavaScript execution time is the Lighthouse and PageSpeed Insights diagnostic that ranks the scripts on a page by the processor time they used while it loaded. It's flagged once parsing and running them takes more than about 1.3 seconds in total. Lighthouse 13 left it unchanged. Download size tells you what a script costs on the network; this diagnostic tells you what it costs the device, which is why a script that feels instant on a laptop can hold up a phone.

What the columns in the table mean

  • URL

    A script the page loaded. Lighthouse lists a script only when it accounted for at least 50 ms of main-thread time.

  • Total CPU Time

    All the main-thread time attributed to that script, including style, layout and other work it triggered, not only its own code. The table is sorted by this column.

  • Script Evaluation

    Time spent running the script's code.

  • Script Parse

    Time spent parsing and compiling the script before it could run.

  • What the limit measures

    The limit applies to Script Evaluation plus Script Parse across the listed scripts, so style and layout time in Total CPU Time doesn't push the result over.

The audit's source code passes it up to 1,282 ms of script time and gives the columns, the 50 ms floor and what the limit adds up. Chrome's execution time guide still gives the older 2 and 3.5 second limits.

Read the table before you change anything

  • High Script Parse points at size: the browser parses and compiles every byte it downloads, whether the code runs or not, so splitting or deleting code helps most. High Script Evaluation points at what the code does when it runs, such as building the whole page in the browser or firing every tag in a tag manager.

  • Check whose scripts fill the top rows. A third-party analytics, chat or ad script can't be edited; the choices are to remove it, load it later or swap it for a lighter one. When a browser extension's script runs for more than 100 ms, the report also warns that extensions affected the load and suggests running it again in an incognito window or a profile without extensions, as the audit's source shows.

How to reduce JavaScript execution time

  1. Rank the scriptsNote the three scripts with the highest Total CPU Time, whether each is yours or a third party's, and whether parsing or running it takes longer.
  2. Remove what the page doesn't useDrop tags and libraries nobody relies on, then check the Reduce unused JavaScript audit for bundles that carry a lot of dead code.
  3. Split the bundle by routeSend each page only the code it needs to start, and load the rest with dynamic imports when visitors reach it. Less code means less to parse as well as less to run.
  4. Render the first view on the serverIf a framework builds the whole page in the browser, server rendering or static generation sends ready HTML, so far less script has to run before content appears.
  5. Start optional scripts laterLoad widgets and trackers that aren't needed for the first view after the page has loaded, so their work doesn't compete with the code that shows your content.

Frequently asked questions

Why is execution time higher in PageSpeed Insights than on my computer?

Its mobile test emulates a mid-tier phone. Lighthouse's throttling docs say mobile runs use a 4x CPU slowdown, and the audit scales its times by that factor, so a script that takes 300 ms on a fast desktop shows as about 1.2 seconds.

Does minifying reduce JavaScript execution time?

A little. Minified files are smaller to download and parse, and Chrome's execution time guide lists minifying and compressing among its fixes. They don't change how much work the code does when it runs, so a script with high Script Evaluation needs less code or less work.

Is this the same as minimize main-thread work?

They overlap. Minimize main-thread work adds up everything the main thread did, grouped by kind of work, while this diagnostic groups the time by script. Use the main-thread breakdown to see whether JavaScript is the problem and this table to see which file.