can delay the display of page content by tens of seconds
and is particularly problematic for users on slow connections.
Chrome therefore blocks the execution of
document.write() in many cases,
meaning you can't rely on it.
In the Chrome DevTools Console you'll see the following message when you use
[Violation] Avoid using document.write().
In the Firefox DevTools Console you'll see this message:
An unbalanced tree was written using document.write() causing
data from the network to be reparsed.
How the Lighthouse
document.write() audit fails
document.write() that weren't blocked by Chrome:
For the most problematic uses,
Chrome will either block calls to
or emit a console warning about them, depending on the user's connection speed.
Either way, the affected calls appear in the DevTools Console.
See Google's Intervening against
article for more information.
Lighthouse reports any remaining calls to
because it adversely affects performance no matter how it's used,
and there are better alternatives.
Each Best Practices audit is weighted equally in the Lighthouse Best Practices Score. Learn more in The Best Practices score.
Remove all uses of
document.write() in your code. If it's being used
to inject third-party scripts, try using
If third-party code is using
ask the provider to support asynchronous loading.
- Source code for Uses
- Intervening against
- Speculative parsing