The minimize main thread work is diagnosed by Pagespeed(Lighthouse) as bad when the main thread works process for longer than 4 seconds during the load.
The thread work can be done either by HTML, CSS, or JS, to turn code into your page.
To solve this diagnostic, it depends on what asset is causing the issues. If it’s 3rd-party, it means your need to optimize it or delay until-user interaction if the plugin is non-essential.
If the code is from your website, it’s probably essential and you need to optimize it. If it’s non-essential, defer or delay it until user interaction.
Use Wp Meteor or Wp Rocket to solve this issue by delaying or deferring.
If you want to optimize code, find better ways to load including many popular scripts such as analytics, loading a leaner version of it.
Identify what causes larger main thread work
After finding what causes the issues, let’s move on to how to fix them.
Remove iframes for script
Iframe elements cannot be changed in the way they load. Consider using a script instead of an iframe. Iframes are also considered bad practice because of security concerns.
To find the keyword either use the asset name or use Chrome Dev Tools; click F12 on Chrome, click the “Network” tab, and hover over “Initiator” to see which file triggered the asset loading:
Place the domain keyword on Flying Scripts.
Delay using WP Rocket
Delaying any 3rd party plugins will also fix the Pagespeed “Reduce the impact of third-party” warning.
(?:wp-content|wp-includes)(.*) /jquery-?[0-9.]*(.min|.slim|.slim.min)?.js js-(before|after)
The reason behind this formula is as follows:
- /jquery-?[0-9.](.min|.slim|.slim.min)?.js – excludes jQuery
- js-(before|after) – exclude inline scripts. Only inline scripts that are added using wp_add_inline_script() will be excluded.
Consider using a smaller captcha such as math challenges, instead of Recaptcha. Set up Cloudflare and enable bot/email protection if it suits your spam/bot fighting.
You also can delay ReCaptcha until user interaction to reduce js exec time, but it needs testing, as smart bots may bypass it.
Ask the developer to improve the plugin
Get your Core Web Vitals optimized. Send a request