Customize Remove Unused CSS parameters
Filters for High CPU caused by Remove Unused CSS
You can change the number of URLs per batch, and the CRON interval of the Remove Unused CSS optimization. This might help to reduce the CPU usage in those cases where it is caused by this optimization.
We have two filters to achieve this:
rocket_rucss_pending_jobs_cron_rows_count: A lower value (default is 100 URLs) can help the server to work on fewer requests at a time.
rocket_rucss_pending_jobs_cron_interval: By setting a higher value (default is 60 seconds), the server will have more time to rest between processing batches.
You can use this helper plugin to achieve it:
Important! You must edit the helper plugin before use!
Only install this plugin if you are comfortable editing files via (S)FTP! This plugin itself works; however, in case something conflicts in your custom environment, you might need to remove this plugin manually via (S)FTP and edit your .htaccess directly.
Instructions to use this helper plugin
- In the helper, the values are already changed so you can install it as it is. Or you can cet your custom values by editing:
- Line 26, to set the batch size. It is the number of URLs that will be processed on each run. The default is 100, the helper will set this to 50.
- Line 46, to set the desired cron interval in seconds. It is the pause that will be applied between the processing of batches. The default is 60 seconds, the helper will set it to 120 seconds
Other Remove Unused CSS filters
Additionally, you can change other parameters such as
- With the
rocket_used_css_dir_levelfilter you can change the allowed subfolders.
The default value is 3 folders.
- Remove Unused CSS will preserve style tags in the page's source code. You can use the
rocket_rucss_preserve_inline_style_tagsfilter can be used to exclude
<style>elements from being preserved.
- If needed, the
rocket_rucss_external_exclusionsfilter can be used to preserve external stylesheets.
- If needed, the
rocket_rucss_inline_content_exclusionsfilter can be used to preserve inline CSS. See further guidance and the related helper plugin in this article.