---
title: "document.write() (bp/document-write)"
description: "document.write blocks parsing, and Chrome skips it on slow connections (Lighthouse: uses document.write())."
url: http://localhost:4173/rules/bp/document-write
updated: 2026-11-11
---

# document.write()

> `bp/document-write` is a vetd rule. It flags: document.write(). It runs on every `check`, together with the TypeScript check.

| Fact | Value |
| --- | --- |
| Rule id | `bp/document-write` |
| Severity | warning |
| Group | Best practices |
| Tags | performance, lighthouse |

## Why it matters

document.write blocks parsing, and Chrome skips it on slow connections (Lighthouse: uses document.write()).

## How to fix it

Insert elements with DOM APIs, or load scripts with next/script.

## Credit

Based on work by:

- [Google Chrome](https://developer.chrome.com/docs/lighthouse/overview): Lighthouse flags document.write() because it delays page load and Chrome blocks it on slow connections.

## References

- [Uses document.write()](https://developer.chrome.com/docs/lighthouse/best-practices/no-document-write), Chrome for Developers
- [Document: write() method](https://developer.mozilla.org/en-US/docs/Web/API/Document/write), MDN Web Docs

## Related rules

- [`perf/sync-script`](http://localhost:4173/rules/perf/sync-script.md)

## Get this text from vetd

MCP: call `explain` with `{ "diagnosticId": "bp/document-write" }`. CLI: `npx vetd explain bp/document-write`.

---

[All 92 rules](http://localhost:4173/rules.md) · Previous: [`a11y/dup-id`](http://localhost:4173/rules/a11y/dup-id.md) · Next: [`bp/unload-listener`](http://localhost:4173/rules/bp/unload-listener.md)
