JavaScript execution time measures how long the browser spends running JavaScript code. Excessive JS execution can block the main thread, making pages feel sluggish.
Why JS execution matters
JavaScript runs on the main thread, which also handles:
- User input processing
- Layout and painting
- Style calculations
Long JS execution blocks these operations, causing:
- Delayed interactions
- Poor INP scores
- Janky scrolling
Measuring JS execution
Tools to measure:
- Chrome DevTools Performance panel
- Lighthouse "Reduce JavaScript execution time"
- Web Vitals library
Reducing JS execution time
Reduce JavaScript
- Remove unused code
- Use tree shaking
- Implement code splitting
Optimize JavaScript
- Avoid expensive operations
- Use efficient algorithms
- Debounce/throttle handlers
Defer JavaScript
- Use
deferorasync - Load on interaction (lazy)
- Use web workers for heavy tasks
Target values
Lighthouse flags JS execution time over 2 seconds. Aim for under 1 second on mobile devices.
Related Terms
Interaction to Next Paint (INP)
A Core Web Vital that assesses page responsiveness by measuring the latency of all user interactions throughout the page lifecycle.
Main Thread
The primary thread in a browser where JavaScript execution, DOM manipulation, and rendering operations occur.
Third-Party Scripts
JavaScript code loaded from external domains, such as analytics, ads, social widgets, and other embedded services.
Total Blocking Time (TBT)
A lab metric that measures the total amount of time the main thread was blocked long enough to prevent input responsiveness.