Thank you for taking the time to listen to our feedback.
The document.write() issue will be related to how the scripts are being injected into the site.
Are you using a plugin to insert adverts ?
Yes – regarding Autoptimize – you should avoid using the option that Aggregates Inline Scripts.