Reduce JavaScript execution time

In PageSpeed, the Reduce JavaScript execution diagnostic comes up when you have JavaScript files loaded from your theme, plugins, or external services, which are taking too much time to be executed by browsers.

reduce JavaScript execution time

Consider reducing the time spent parsing, compiling, and executing JS. You may find delivering smaller JS payloads helps with this. Learn how to reduce Javascript execution time.

Understanding Reduce JavaScript execution time

Once it's downloaded, the JavaScript of your site has to be "read" and "understood" by the browser, and then executed.

The more JavaScript there is, the more time the browser will need to spend on it, and the longer it takes to load your website.

PageSpeed will display a warning when JavaScript execution takes more than 2 seconds, and it will fail when it takes longer than 3.5 seconds.

How to reduce JavaScript execution time

Ideally, to fully address this recommendation, you would need to remove from your site those problematic scripts. 

On the other hand, WP Rocket can help improve this diagnostic with these features:

  • Load JavaScript deferred - To defer the heavy-execution JavaScript files and prioritize the rendering of the page.
  • Delay JavaScript execution - To delay the execution of the JavaScript files while loading the page and until there is user interaction.

Alternatively, these third-party plugins can help you remove slow scripts from your pages. Please use them with care because it can break the functionality of your site and consult your developer if you need help.

Did this answer your question? Thanks for the feedback There was a problem submitting your feedback. Please try again later.