Customize Remove Unused CSS parameters

This article shows how you can customize the parameters that control the speed of the Used CSS generation related to the Remove Unused CSS feature.

The Remove Unused CSS parameters are two:

  • The batch size, which is the number of URLs for which the Used CSS is generated in each run. The default batch size is 100 (URLs).
  • The cron interval, which is the wait time between the processing of batches. By default, the cron interval is 60 (seconds).

Controlling the parameters can be useful in cases where the Remove Unused CSS feature causes a high CPU usage problem

Using a helper plugin

You can use a helper plugin to control the parameters, and limit the speed of the Used CSS generation. With this helper plugin, the speed of the Preload option will also be limited.

The helper plugin and more information about how it works can be found here.

Additional customization of the parameters

If you need to decrease the speed of the Used CSS generation, or to increase the speed, you can apply additional customizations to the above helper plugin as shown below.

Important! In this part, you must edit the helper plugin before use! 
Only proceed if you are comfortable editing files via (S)FTP!

You can set your custom values to this helper plugin by editing:

  • Line 91, to set the batch size. It is the number of URLs that will be processed on each run.
    • Decrease in case the default value is causing a higher CPU usage. This will result in the server running shorter tasks.
    • Increase progressively if you have enough resources to process long standing tasks.
  • Line 112, to set the desired cron interval in seconds. It is the pause that will be applied between the processing of batches.
    • Increase in case the default value is causing a higher CPU usage. The server will have more time to rest between processing batches.
    • Decrease progressively if you don't notice any increase in CPU load.

Then, compress the helper as ZIP, upload it and activate it.

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