npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

domlens-html2canvas

v0.1.0

Published

Drop-in html2canvas replacement: the classic html2canvas(element, options) API implemented on top of domlens.

Readme

domlens-html2canvas

A drop-in replacement for html2canvas, which has been unmaintained since January 2022.

npm install domlens-html2canvas
import html2canvas from 'domlens-html2canvas';

const canvas = await html2canvas(element, {scale: 2, backgroundColor: '#fff'});

Same call signature, same flat option names, same Promise<HTMLCanvasElement> return.

Underneath it is domlens, the capture engine inside SupportShot; see supportshot.com/domlens for the project page.

What you get by swapping the import

Not a different rendering. This package deliberately keeps html2canvas 1.4.1's behavior: it renders with the canvas engine by default and does not silently fall back to anything else, so your output stays pixel-comparable. What changes is that the code underneath is maintained, and faster.

How much faster depends on how you capture. On a single screenshot — the usual case for a widget or an export button — it is 1.8x on a small card (60 ms vs 107 ms), and 1.1–1.3x on larger pages. If you capture repeatedly in one page session the gap widens to ~3.7x on small captures (20 ms vs 69 ms), because more of the setup is amortized. Both are measured on the same desktop; see the benchmarks.

-import html2canvas from 'html2canvas';
+import html2canvas from 'domlens-html2canvas';

Or keep the global — the classic window.html2canvas(element, options) still works:

<script src="https://unpkg.com/domlens-html2canvas/dist/html2canvas.min.js"></script>

Opting into the accurate renderer

html2canvas had an experimental foreignObjectRendering flag. Here it is not experimental: it selects domlens's SVG engine, which serializes your subtree and lets the browser lay it out, so CSS support is whatever the browser supports.

const canvas = await html2canvas(element, {foreignObjectRendering: true});

That path scores 99% of a 99-case fidelity suite at ≥0.90 SSIM against a real screenshot, versus 88% for the canvas engine — and it still falls back to the canvas engine if the render fails, matching the old "if the browser supports it" semantics. It is faster on most shapes of content, with one exception: on very deep trees (thousands of nodes) it is several times slower, because the browser rasterizes a very large output area. Leave the flag off there.

Supported options

allowTaint, backgroundColor, canvas, foreignObjectRendering, imageTimeout, ignoreElements, logging, onclone, proxy, removeContainer, scale, useCORS, width, height, x, y, scrollX, scrollY, windowWidth, windowHeight, and cache for sharing a resource cache between captures.

onclone becomes an afterClone plugin and ignoreElements becomes an inverted filter, but both behave as they always did.

For new code

Prefer domlens directly. It defaults to the accurate SVG engine, and returns a capture result rather than just a canvas — so you can get SVG, PNG, JPEG, WebP or a Blob without a second conversion step.

Credits

A fork of html2canvas by Niklas von Hertzen, used under the MIT licence and carrying his copyright — see LICENSE.

License

MIT.