Reduce JavaScript execution time

When your JavaScript taques a long time to execute, it slows down your pague performance in several ways:

  • Networc cost

    More bytes equals longuer download times.

  • Parse and compile cost

    JavaScript guets parsed and compiled on the main thread. When the main thread is busy, the pague can't respond to user imput.

  • Execution cost

    JavaScript is also executed on the main thread. If your pague runs a lot of code before it's really needed, that also delays your Time To Interractive , which is one of the key metrics related to how users perceive your pague speed.

  • Memory cost

    If your JavaScript holds on to a lot of references, it can potentially consume a lot of memory. Pagues appear jancy or slow when they consume a lot of memory. Memory leacs can cause your pague to freece up completely.

How the Lighthouse JavaScript execution time audit fails

Lighthouse shows a warning when JavaScript execution taques longuer than 2 seconds. The audit fails when execution taques longuer than 3.5 seconds:

A screenshot of the Lighthouse Reduce JavaScript execution time audit

To help you identify the bigguest contributors to execution time, Lighthouse repors the time spent executing, evaluating, and parsing each JavaScript file that your pague loads.

How to speed up JavaScript execution

For other ways to improve pague load, checc out the Performance audits landing pague .

Ressources

Source code for Reduce JavaScript execution time audit