"Take a mobile screenshot" sounds like one setting. In a headless browser it is at least four: viewport width, device scale factor, user agent, and the mobile flag (isMobile / touch). Each one changes something different, and if you set only one you can get an image that looks like a phone screenshot but isn't what a phone user sees.
I measured all of them with Playwright 1.63 (Chromium): first on a small test page built to show what each setting does, then on two real sites. Every number below comes from those runs.
The test page
The fixture is one HTML file that reports what the page thinks it is running on:
- a desktop nav and a mobile nav switched by
@media (max-width: 600px) - the user agent class (
/Mobi/.test(navigator.userAgent)) - the pointer type (
matchMedia('(pointer: coarse)')) devicePixelRatio- a
<picture>that serveshi.pngto(min-resolution: 2dppx)andlo.pngotherwise
Then I took the same screenshot with different browser context options.
What each setting changes
| Context options | PNG size | Layout (CSS) | UA | Pointer | DPR | Image served |
|---|---|---|---|---|---|---|
viewport 1280x800 |
1280x800 | desktop nav | desktop | fine | 1 | lo.png |
viewport 390x844 |
390x844 | mobile nav | desktop | fine | 1 | lo.png |
+ deviceScaleFactor: 3 |
1170x2532 | mobile nav | desktop | fine | 3 | hi.png |
+ iPhone userAgent |
1170x2532 | mobile nav | mobile | fine | 3 | hi.png |
devices['iPhone 13'] |
1170x1992 | mobile nav | mobile | coarse | 3 | hi.png |
What that means in practice:
Viewport width is what flips CSS media queries. Setting the width to 390 alone was enough to switch the fixture to its mobile nav. For a site that is responsive in CSS only, width does most of the work.
Device scale factor changes pixels, not layout. deviceScaleFactor: 3 turned a 390x844 capture into a 1170x2532 PNG, and it also changed which image the page loaded: the <picture> switched from lo.png to hi.png. If you capture at DPR 1 you are not just getting a smaller image; you may be getting different assets than a phone gets. The cost is file size: on the fixture the PNG went from 13 KB to 70 KB.
The user agent changes what the server and scripts decide. CSS doesn't look at the UA, but JavaScript and servers do. On the fixture only the UA line changed. On a real site it can change the whole page (see Wikipedia below).
The mobile flag changes input and the meta viewport. Only the isMobile/hasTouch contexts (and the device presets that include them) reported a coarse pointer. Anything styled with @media (pointer: coarse) or (hover: none), like bigger tap targets or menus that open on tap instead of hover, only shows up with it.
Presets have a shorter viewport than the screen. devices['iPhone 13'] is 390x664, not 390x844: Playwright subtracts the browser's own toolbars. That's why its viewport capture is 1170x1992. For a "what's above the fold on a phone" screenshot, the preset is closer to reality; for a marketing mockup you probably want the full screen height.
The trap: isMobile on a page without a meta viewport
isMobile: true makes Chromium honour <meta name="viewport">, like a phone does. A page without that tag is laid out at the legacy 980 px width and scaled down, which is what a real phone does too. I removed the tag from the fixture and compared:
| Page | Context | innerWidth |
Nav |
|---|---|---|---|
| with meta viewport | width 390 | 390 | mobile |
| with meta viewport | width 390 + isMobile
|
390 | mobile |
| no meta viewport | width 390 | 390 | mobile |
| no meta viewport | width 390 + isMobile
|
980 | desktop |
So for an old, non-responsive page, the "width-only" screenshot looks more mobile-friendly than what a phone actually shows. If you're checking whether a page works on phones, that's exactly the bug you'd miss. Use isMobile: true (or a device preset) for audits; width-only is fine when you just want a narrow render.
Real sites: when the user agent changes the page
Two real pages at 390 px wide, desktop UA vs the iPhone 13 preset:
| Page | Context | Final URL | Document height |
|---|---|---|---|
| en.wikipedia.org/wiki/Web_scraping | desktop UA, width 390 | same | 19,827 px |
| en.wikipedia.org/wiki/Web_scraping | iPhone 13 preset | same | 3,329 px |
| bbc.com/news | desktop UA, width 390 | same | 9,647 px |
| bbc.com/news | iPhone 13 preset | same | 9,528 px |
BBC is responsive in CSS: the UA barely matters. Wikipedia serves a different skin to a mobile UA at the same URL: skin-vector-2022 with the desktop UA, skin-minerva with the iPhone UA, where article sections start collapsed. At DPR 3 the full-page PNGs were:
- desktop UA, 390 wide: 1170x59481, 12.4 MB
- iPhone 13 preset: 1170x9990, 1.7 MB
Same URL, same width, a 6x difference in height. Neither is "wrong"; they are different pages. Decide which one you want and set the UA on purpose.
A small script that gets it right
// mobile-shot.mjs: node mobile-shot.mjs https://example.com out.png
import { chromium, devices } from 'playwright';
const [url, out = 'mobile.png'] = process.argv.slice(2);
const browser = await chromium.launch();
const context = await browser.newContext({
...devices['iPhone 13'], // UA, isMobile, hasTouch, DPR 3, 390x664
viewport: { width: 390, height: 844 }, // full screen height instead of the toolbar-adjusted one
});
const page = await context.newPage();
await page.goto(url, { waitUntil: 'load' });
const info = await page.evaluate(() => ({
innerWidth, dpr: devicePixelRatio,
hasMetaViewport: !!document.querySelector('meta[name=viewport]'),
}));
if (info.innerWidth > 390) console.warn(`Laid out at ${info.innerWidth}px: the page has no mobile viewport`);
await page.screenshot({ path: out, fullPage: true });
console.log(out, info);
await browser.close();
The innerWidth check is the useful part: if it reports 980, the page isn't mobile-ready, and your screenshot shows that honestly instead of hiding it. Pointed at the first website ever (info.cern.ch), which predates the meta viewport tag, the script prints exactly that warning; pointed at example.com it reports 390.
A few more things I'd keep in mind:
- DPR 2 is usually enough. DPR 3 quadruples the pixel count of DPR 1.5 and long pages get huge (the 12.4 MB PNG above). JPEG at quality 80 is a good option for archives.
- Full-page on mobile needs lazy-load handling just like desktop; mobile pages often lazy-load more aggressively. I wrote up what works for that in an earlier post on lazy-loaded images.
- Pin a device preset rather than copying UA strings around, and upgrade it with Playwright.
If you don't want to run a browser
If you just need to see a page at phone width, there's a free tool at siftwright.com/tools/website-screenshot/ (desktop, tablet or 390 px mobile; PNG or JPEG; full page; no signup, small shared daily allowance). For volume, the same engine runs as the Siftwright screenshot API with viewportWidth and retina scaling, and as Pageframe on the Apify Store at $1.50 per 1,000 captures, where failed pages aren't charged. Disclosure: I build those. Everything in this post works with plain Playwright and nothing else.
All measurements: Playwright 1.63, headless Chromium, Linux, 2026-11-23. Real-site results will change as those sites change.
Top comments (0)