Reduce JavaScript execution time

💡 Enable Delay JavaScript Execution in WP Rocket to improve this recommendation

You get this Diagnostic because you have JavaScript (JS) files, loaded from your theme, plugins or from external services which are taking too much time to be executed by browsers.

The recommendation says:

Consider reducing the time spent parsing, compiling, and executing JS. You may find delivering smaller JS payloads helps with this

This means that JS, once downloaded, has to be "read" and "understood" by the browser (parsed and compiled) and is then executed within the browser. 

The more JS there is, the more time the browser will need to parse, compile and execute it. 

PageSpeed Insights shows a warning when JavaScript execution takes longer than 2 seconds in the browser. The audit fails when execution takes longer than 3.5 seconds:

How to find the problematic files

To help you identify the biggest contributors to execution time, Lighthouse reports the time spent executing, evaluating, and parsing each JavaScript file that your page loads. 

In the example above, the JS files are combined into one single JS file by WP Rocket, so you can’t see which file(s) take too much time. 

To identify these scripts in detail, analyze your non-cached version bypassing WP Rocket adding the ?nowprocket query to your URL (i.e: http://www.yourdomain.com/?nowprocket) then you can identify the theme/plugin responsible:

rbtools.min.js from RevSlider plugin is the JS script which consumes the most CPU Time here.

How WP Rocket can help

The Delay JavaScript Execution option should help improve this recommendation.

What else can I do?

Ideally, to address this recommendation, you’ll have to remove some plugins scripts, some scripts from your theme and external scripts, and WP Rocket cannot decide this or automate this for you. 

You’ll perhaps have to reconsider the use of a slider at the top of your page and maybe replace it by a static image. Perhaps you’ll have to remove this social network widget from your sidebar that is calling a lot of third-party scripts (i.e: from another domain) you can find in this recommendation, this could really make a difference in terms of performance. 

Here are also a few third party plugins that can help you remove slow JS 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.

And if you need custom development, we have partnered with Codeable, you can find more details about it here: https://wp-rocket.me/resources/codeable/

Not a WP Rocket customer yet?
Read our article about How to reduce JavaScript execution time and learn how to address this PageSpeed Insights recommendation with and without a plugin.

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