Avoid Document write
Heads up! This is a developer-level document. You need to be one or hire one to implement this optimization. It may require changes to code in your theme or a plugin.
What is document.write()?
How does document.write impact performance?
In this example, the function blocks the page rendering until the injected script tag is parsed and the source is downloaded.
If document.write() is used only once in the site code, normally there won’t be a big impact but Google Page Insights will continue to complain about this.
In any case, it is advisable to avoid using this to comply with Google Page Insights.
You can find out if your site has a document.write() execution in several ways :
Browser Console - Chrome
Google PageSpeed Audit / Lighthouse: Avoid document.write()
What can I do to avoid document.write() on my page?
This function is normally added by a plugin or your theme. In these cases the only thing you can do is either ask the original developers of the plugin / theme to fix this in the code or install an alternative that uses a different approach to add code to the HTML. This is related to how the code is written, so WP Rocket cannot fix this, but the original developer can.
How does WP Rocket handle document.write?