A Clean Build Doesn't Mean Your Site Works
Nov 22, 2026
It's been a while. Since my last post I've been heads-down building websites for small businesses, and these days a good chunk of that building is done alongside AI coding agents. They're fast. They're also very confident.
A few months back I handed an agent a spec I'd written for a client's homepage. It built the page and reported it as code complete. The Eleventy build was clean, no errors, no warnings. I opened it on my phone and the page slid sideways. It had about 400px of horizontal scroll, a text column crushed to a third of its row on a wide monitor, a photo caption sitting beside the photo instead of under it, and a call-to-action button too small to comfortably tap. Nine problems in total, and I could see every one of them the moment I looked at the page.
I keep relearning this: a passing build proves your templates compiled, and nothing about whether the page is usable.
Goal
Look at the rendered page, at the screen widths people actually use, every time, before calling it done.
I don't trust myself to do that by hand on every change (I won't), so I wrote a small script that does it for me.
The Script
You'll need Playwright: npm install -D playwright, then npx playwright install chromium. Save this as check-widths.mjs:
import { chromium } from 'playwright';
const url = process.argv[2] ?? 'http://localhost:8080/';
const widths = [390, 430, 768, 1024, 1440, 1920];
const browser = await chromium.launch();
for (const width of widths) {
const page = await browser.newPage({ viewport: { width, height: 900 } });
await page.goto(url, { waitUntil: 'networkidle' });
const { scroll, client, inner } = await page.evaluate(() => ({
scroll: document.documentElement.scrollWidth,
client: document.documentElement.clientWidth,
inner: window.innerWidth,
}));
if (inner !== width) console.warn(`Asked for ${width}px, got ${inner}px`);
const status = scroll > client ? `OVERFLOW by ${scroll - client}px` : 'ok';
console.log(`${width}px: ${status}`);
await page.screenshot({ path: `shot-${width}.png`, fullPage: true });
await page.close();
}
await browser.close();Start your dev server and run node check-widths.mjs http://localhost:8080/. You'll get a line per width and a full-page screenshot for each.
The overflow check compares scrollWidth to clientWidth. If the page is wider than the window, something is poking out past the edge and anyone on a phone can drag the page sideways.
The script also checks that it got the viewport it asked for. Screenshot tools will occasionally hand you an image at a different size than you requested, and then you're reviewing the wrong page without knowing it.
1920 is not optional. If a container is capped at 1600px, every width below that looks identical. The bug only shows up once the screen is wider than the cap.
Finding the Culprit
When the script reports overflow, paste this into the browser console at that width to find the offending element:
[...document.querySelectorAll('*')].filter(
(el) => el.getBoundingClientRect().right > document.documentElement.clientWidth
);The last element in that list is usually your culprit, or close to it. Fix it, rerun the script, then open the screenshots and scroll through them before you call it done.



Comments
Leave a Comment