<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Alice Wu</title>
    <description>The latest articles on DEV Community by Alice Wu (@alicewu).</description>
    <link>https://dev.to/alicewu</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4234731%2F381a2799-5dc6-4005-848a-f821aeec323b.png</url>
      <title>DEV Community: Alice Wu</title>
      <link>https://dev.to/alicewu</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/alicewu"/>
    <language>en</language>
    <item>
      <title>How to Take Full-Page Screenshots in the Browser — Without a Server</title>
      <dc:creator>Alice Wu</dc:creator>
      <pubDate>Thu, 19 Nov 2026 10:00:53 +0000</pubDate>
      <link>https://dev.to/alicewu/how-to-take-full-page-screenshots-in-the-browser-without-a-server-19gd</link>
      <guid>https://dev.to/alicewu/how-to-take-full-page-screenshots-in-the-browser-without-a-server-19gd</guid>
      <description>&lt;p&gt;"Take a screenshot of this entire page" sounds trivial until you actually try to build it. The viewport is easy — getDisplayMedia or a simple canvas grab handles that. But full-page capture, where the user gets one clean image of everything from header to footer including content that was never on screen, is a genuinely interesting browser problem.&lt;br&gt;
I've spent the last few weeks wrestling with this while building a small screenshot utility. Here are the three approaches that actually work in 2026, what each one costs you, and the edge cases that will eat your weekend.&lt;br&gt;
Approach 1: The naive scroll-and-stitch&lt;br&gt;
The instinctive approach: scroll through the page, capture each viewport, stitch the strips into one canvas.&lt;br&gt;
async function captureStrips(pageHeight, viewportHeight) {&lt;br&gt;
  const strips = [];&lt;br&gt;
  for (let y = 0; y &amp;lt; pageHeight; y += viewportHeight) {&lt;br&gt;
    window.scrollTo(0, y);&lt;br&gt;
    await waitForNextPaint(); // critical — more on this below&lt;br&gt;
    strips.push(await captureViewport());&lt;br&gt;
  }&lt;br&gt;
  return stitch(strips);&lt;br&gt;
}&lt;br&gt;
It works. It's also fragile in ways that only show up in production:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Fixed-position elements (sticky headers, cookie banners, floating chat buttons) appear in every strip. Your stitched screenshot looks like the site has 12 identical headers stacked vertically.&lt;/li&gt;
&lt;li&gt;Lazy-loaded content pops in as you scroll, so a strip captured at scroll position 4,000px might catch an image mid-fade-in.&lt;/li&gt;
&lt;li&gt;Scroll-triggered animations mean the page may literally be a different height by the time you finish capturing.
The waitForNextPaint() call matters more than people expect. Without it, captureViewport() races the browser's compositor and you get torn frames. A reliable implementation:
function waitForNextPaint() {
return new Promise(resolve =&amp;gt; {
requestAnimationFrame(() =&amp;gt; {
  requestAnimationFrame(resolve); // double rAF: after layout AND paint
});
});
}
Approach 2: SVG foreignObject — the clever one
Instead of capturing pixels, you can re-render the DOM as an image: clone the DOM node, inline all computed styles, wrap it in an SVG , serialize it, and draw that SVG onto a canvas.
async function domToImage(node) {
const clone = node.cloneNode(true);
inlineStyles(clone);          // copy computed styles onto the clone
const svg = &lt;code&gt;
![svg](data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIke25vZGUuc2Nyb2xsV2lkdGh9IgogICAgICAgICBoZWlnaHQ9IiR7bm9kZS5zY3JvbGxIZWlnaHR9Ij4KICAgICAgPGZvcmVpZ25PYmplY3Qgd2lkdGg9IjEwMCUiIGhlaWdodD0iMTAwJSI+CiAgICAgICAgJHtuZXcgWE1MU2VyaWFsaXplcigpLnNlcmlhbGl6ZVRvU3RyaW5nKGNsb25lKX0KICAgICAgPC9mb3JlaWduT2JqZWN0PgogICAgPC9zdmc+)&lt;/code&gt;;
const blob = new Blob([svg], { type: 'image/svg+xml' });
const url = URL.createObjectURL(blob);
const img = new Image();
img.src = url;
await img.decode();
return drawToCanvas(img);
}
This is how most "in-browser full-page screenshot" libraries work under the hood. The advantages are real:&lt;/li&gt;
&lt;li&gt;No scrolling — the page never moves, so no fixed-element duplication&lt;/li&gt;
&lt;li&gt;No timing races with lazy loading&lt;/li&gt;
&lt;li&gt;The output is deterministic: same DOM, same render
But there's a wall you hit immediately: the canvas taint rules. Any external resource — an image from another origin, a webfont loaded from a CDN — that gets inlined into the SVG will taint the canvas, and canvas.toBlob() will throw a SecurityError.
The workarounds:&lt;/li&gt;
&lt;li&gt;Fetch external images through your own proxy (requires a server — defeats the point of a no-server build)&lt;/li&gt;
&lt;li&gt;Convert images to data URLs via fetch + FileReader — only works for CORS-friendly origins&lt;/li&gt;
&lt;li&gt;Accept degraded output when tainting would occur and fall back to approach 1
Webfonts need special handling too: foreignObject rendering won't load fonts referenced by CSS @font-face unless you embed them as data URLs in an inlined stylesheet first. Skip this step and your beautiful page renders with a default serif font.
Approach 3: The Chrome-only escape hatch
If your target is Chrome and Edge only, the DevTools protocol has a first-class solution:
// In an extension or a CDP-connected context:
const { data } = await client.send('Page.captureScreenshot', {
format: 'png',
captureBeyondViewport: true  // the magic flag
});
captureBeyondViewport: true renders the full page height in one shot — no stitching, no SVG serialization, pixel-perfect fonts and images. This is what browser extensions use, and honestly, if you're building an extension, stop reading and use this.
The catch: it's not available to a plain web page. A website can't send CDP commands to the browser it runs in. So the "pure web page" path is stuck choosing between approaches 1 and 2.
Choosing between them
Scroll &amp;amp; stitch
foreignObject
CDP
Fixed elements
❌ duplicated
✅ fine
✅ fine
External images
✅ fine
⚠️ taint risk
✅ fine
Webfonts
✅ fine
⚠️ must inline
✅ fine
Works on any page
✅
⚠️ CSP blocks data-URI SVG on some sites
❌ extension only
Output fidelity
medium
high (if assets resolve)
pixel-perfect
My current rule of thumb: try foreignObject first for pages without heavy cross-origin assets, fall back to scroll-and-stitch with double-rAF timing when it fails, and reach for the CDP flag whenever an extension context is available.
The bugs that surprised me
Three things nobody warned me about:&lt;/li&gt;
&lt;li&gt;Infinite scroll pages have no bottom. A full-page capture of an infinite-scroll feed means defining what "the page" even is. I cap capture height and add a note in the output ("page truncated at 20,000px").&lt;/li&gt;
&lt;li&gt;Zoom levels break coordinates. At browser zoom ≠ 100%, scrollWidth, device pixels, and CSS pixels all disagree. Multiply everything by devicePixelRatio and respect zoom — and test at 90%, 100%, and 125%, because they fail differently.&lt;/li&gt;
&lt;li&gt;Canvas size limits. Chrome caps canvas dimensions around 16,384px on a side. A very long page will exceed this at high DPI. Scale the output down or split into multiple images.
Wrapping up
Full-page capture in the browser is a layered problem: the DOM approach gets you fidelity, the scroll approach gets you compatibility, and the CDP approach gets you perfection when you're allowed to use it. None of them alone covers every page — which is, I suppose, why screenshot tools still exist as a product category.
I'll write a follow-up on handling mixed-DPI multi-monitor setups next — that one took longer to solve than all of the above combined.
What edge cases have you hit building capture or rendering tools? The DPI one still gives me nightmares.&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>frontend</category>
      <category>javascript</category>
      <category>tutorial</category>
      <category>webdev</category>
    </item>
  </channel>
</rss>
