Why document.write is slow and how to replace it
document.write blocks parsing and Chrome may ignore it on slow connections. Insert elements with DOM methods instead.
Step by step, with screenshots: Console errors and deprecated APIs: what the report flags →
Check your own site
Runs this check and the other 186, free, in about 45 seconds.
What a passing site looks like
- document.write() is not usedwarning · −1 ptseffort M
document.write() usage
Why it matters. document.write blocks the page until the injected script arrives, and Chrome drops such scripts on slow connections, so the ad or widget simply does not appear.
- Replace document.write with a normal <script async> tag or by appending the element from JavaScript.
- Update the ad or widget snippet; most vendors now provide an async version.