You can load a browser-ready distribution of html-to-image from a CDN, but do not assume that its npm import example becomes a global variable when placed in a plain script tag. Pin the package version, load the chosen browser bundle before your own code, and verify the export exposed by that exact file. The project documents its package imports and image-export functions, but not one guaranteed global name for every CDN artifact. For a bundled application, install the package and use its documented module import instead. The project README is the reference for the API and rendering behavior.
Choose the right way to load the library
The right loading method depends on whether your page is built or just uses HTML and script tags:
- Plain HTML page or quick demo: use a browser-ready CDN distribution file, pin its version, and confirm what global or module export that exact file provides before calling it.
- Application using a build tool: install
html-to-imagefrom npm and import it as the project documents. This avoids relying on an undocumented global name.
The npm example import { toPng } from 'html-to-image' is a JavaScript module import. It is not a demonstrated recipe for a classic <script> tag. A CDN can serve different file formats, and the file format determines how you can access the library.
The package listing and jsDelivr file listing showed version 1.11.13 when checked on September 29, 2026; the project release history dates that release to February 14, 2025. Check the listings before using the example because versions and CDN files can change. npm package listing · jsDelivr package files · Project releases
Quick wins for a faster PC:
Scan for outdated or missing drivers - takes under a minuteDriver Scan →Clear out junk files and repair common Windows errorsFree Scan →Fix the driver behind crashes, sound loss and screen glitchesFind Drivers →#1 Best Overall
- Battery-Free Pen: StarG640 drawing tablet is the perfect replacement for a traditional mouse! The XPPen advanced Battery-free PN01 stylus does not require charging, allowing for constant uninterrupted Draw and Play, making lines flow quicker and smoother, enhancing overall performance
- Ideal for Online Education: XPPen G640 graphics tablet is designed for digital drawing, painting, sketching, E-signatures, online teaching, remote work, photo editing, it's compatible with Microsoft Office apps like Word, PowerPoint, OneNote, Zoom, Xsplit etc. Works perfect than a mouse, visually present your handwritten notes, signatures precisely
- Compact and Portable: The G640 art tablet is only 2 mm thick, it's as slim as all primary level graphic tablets, allowing you to carry it with you on the go
- Chromebook Supported: XPPen G640 digital drawing tablet is ready to work seamlessly with Chromebook devices now, so you can create information-rich content and collaborate with teachers and classmates on Google Jamboard’s whiteboard; Take notes quickly and conveniently with Google Keep, and effortlessly sketch diagrams with the Google Canvas
- Multipurpose Use: Designed for playing OSU! Game, digital drawing, painting, sketch, sign documents digitally, this writing tablet also compatible with Microsoft Office programs like Word, PowerPoint, OneNote and more. Create mind-maps, draw diagrams or take notes as replacement for mouse
Load a pinned CDN file in a plain HTML page
This example loads the version-pinned jsDelivr distribution file listed for 1.11.13 and waits for it to finish loading before attempting a capture. Its one important qualification is that the project README does not establish window.htmlToImage as the global export for this file. Inspect the selected distribution or its documentation and replace the marked access point with the export it actually exposes. Do not treat the code as ready to run unchanged until you have confirmed that name.
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Capture a DOM element</title>
<style>
#card { width: 320px; padding: 24px; color: #172033; background: #eef3ff; }
</style>
</head>
<body>
<div id="card"><h1>Sample card</h1><p>This element will be exported.</p></div>
<button id="capture" type="button">Create PNG</button>
<a id="download" download="card.png">Download PNG</a>
<p id="status" role="status"></p>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/html-to-image.min.js"></script>
<script>
const button = document.getElementById('capture');
const status = document.getElementById('status');
const download = document.getElementById('download');
button.addEventListener('click', async () => {
const node = document.getElementById('card');
try {
// Replace this access with the export confirmed for this exact bundle.
const dataUrl = await window.htmlToImage.toPng(node);
download.href = dataUrl;
status.textContent = 'PNG ready. Use the download link.';
} catch (error) {
status.textContent = `Capture failed: ${error.message}`;
console.error(error);
}
});
</script>
</body>
</html>
The script tag appears before the code that uses the library, so the browser has an opportunity to load the CDN file first. For production, handle a failed script load as well: add an onerror handler or attach a load listener, show a useful message, and avoid calling the API until loading succeeds. The code catches errors from the asynchronous image conversion; it cannot make an incorrect export name work.
Verify the bundle export instead of guessing
- Open the exact versioned file listed in the jsDelivr package listing and check whether it is a browser bundle, module, or another format.
- Check the package files and project documentation for how that artifact exposes its API. Do not infer the global name from the npm import syntax.
- Update the call site to match that export, then test the page in the browser console. If the artifact is an ES module rather than a classic-script bundle, load it with a module-compatible approach or use a build tool rather than treating it as a global.
- Keep the tested package version and CDN URL together. When updating the version, check the file path and export again.
A third-party reference page lists CDN paths for version 1.11.13 through jsDelivr, cdnjs, and unpkg. Treat the precise files and any integrity metadata on that page as details to verify against the current asset, not as a promise that every path or hash will stay valid. Third-party CDN reference
Rank #2
- Customize Your Workflow: The 6 customizable press keys on Huion H640P drawing tablet for pc let you assign your most-used commands—like undo, zoom, brush switch, or save—so you can keep your hands on the tablet and your mind on the art. Whether you're a digital painter switching brushes, or a comic artist zooming in and out, these keys keep your workflow smooth and uninterrupted. Plus, the Huion driver lets you save different shortcut profiles for different apps, so you never have to reconfigure when switching software.
- Professional Pen Performance: Huion H640P drawing pad for computer comes with the battery-free PW100 stylus that's always ready when inspiration strikes. With 8192 levels of pressure sensitivity, every light sketch, or bold stroke responds naturally to your hand—just like a real pen. The 5080 LPI resolution and 233 PPS report rate deliver lag-free, precise strokes, so you can draw confidently without second-guessing your cursor. The pen side buttons help you switch between pen and eraser instantly.
- Compact and Portable: Huion H640P computer graphics tablet features a compact, ultra-portable design at just 0.3 inches thin and 0.61 lbs light, so it slides easily into your backpack—perfect for sketching in coffee shops, taking notes in class, or editing on the go between home and studio. The 6x4 inch active area offers enough room for natural pen movements while fitting comfortably on crowded desks, or lecture hall seats.
- Stable Compatibility: Huion H640P graphic drawing tablet works seamlessly with Mac, Windows, Linux PCs, and Android smartphones/tablets (OS version 6.0 or later). Left-handed friendly, and you just need to flip the tablet and adjust the settings in the driver. Please note: H640P does NOT support iPhone/iPad.
- Move Beyond the Mouse: Huion Inspiroy H640P is a pen tablet that replaces your mouse for more natural, precise control. Freehand draw, take notes, or even play OSU—everything you do with a mouse, you can do better with a pen. The precise tip makes it ideal for detailed photo editing, graphic design, or signing PDF. Meanwhile, the ergonomic pen grip helps you avoid the strain that comes from hours of using a mouse.
Install and import it in a bundled application
If your application already uses a bundler or package-aware build system, use the package import documented by the project rather than trying to adapt a browser global:
Do these 3 things before closing this tab:
1Scan for outdated or missing drivers - takes under a minute2Clear out junk files and repair common Windows errors3Fix the driver behind crashes, sound loss and screen glitchesnpm install html-to-image
import { toPng } from 'html-to-image';
const node = document.getElementById('card');
if (!node) throw new Error('Capture element #card was not found');
try {
const dataUrl = await toPng(node);
const link = document.createElement('a');
link.download = 'card.png';
link.href = dataUrl;
link.click();
} catch (error) {
console.error('Could not create PNG:', error);
}
The project also documents namespace imports, such as import * as htmlToImage from 'html-to-image', and CommonJS require('html-to-image'). Use the form compatible with your project’s module system and build configuration. The package’s documented examples and export details are in the README.
Choose the output function that fits the next step
Pass a DOM node to an export function. The top-level functions return Promises, so wait for the result and handle rejection rather than treating conversion as a synchronous operation.
Rank #3
- Ultra thin tablet: Active Area 4 x 3 inches. Fully utilizing our 8192 levels of pen pressure sensitivity―Providing you with groundbreaking control and fluidity to expand your creative output. Please note: The 4 x 3 inches is very small, please confirm that it will meet your needs before you purchase it
- OSU game: Designed for OSU! gameplay, drawing, painting, sketching, E-signatures etc. No need to install drivers for OSU! It's also designed for both right and left hand users
- Accurate Pen Performance: StarG430S computer graphics tablet is the perfect replacement for a traditional mouse! The XPPen advanced Battery-free PN01 stylus does not require charging, allowing for constant uninterrupted Draw and Play, making lines flow quicker and smoother, enhancing overall performance
- Compact and Portable: The G430S art tablet is only 2 mm thick, it’s as slim as all primary level graphic tablets,Ultra-thin and portable, allowing you hold it in one hand and carry it on the go. This graphic drawing tablet supports Mac. However, since the product interface is micro USB to USB-A, if your computer is a Mac and does not have a USB-A port, you will need to purchase an OTG transfer adapter to ensure compatibility with your Mac. So please confirm your computer port before you purchase it
- PLEASE NOTE: The XPPen StarG 430 is compatible with the Windows system 11/10/8/7(32/64 bit), and the Mac OS X version 10.10 or later, but it is incompatible with iOS and iPad OS. If your computer is a Mac, you need to grant permission to the Mac preferences first. Please go to our official website, and according to the guide: XPPen>Support>FAQ, find out the Star G430 and click, then click the question according to your Mac system. There are detailed guidelines for installing the driver so your tablet will work correctly. It's possible incompatible with the customer's own EMR system or other signature system. Please feel free to contact us to confirm the compatibility before your purchase
| Function | Result | Use it when |
|---|---|---|
toPng(node) |
PNG data URL | You want a common raster image that can be displayed or used as a download link. |
toJpeg(node, options?) |
JPEG data URL | You need JPEG output; consult the project API for supported options such as quality. |
toSvg(node) |
SVG data URL | You need the serialized SVG representation. |
toBlob(node) |
Blob | You want a blob for a download, upload, or object URL workflow. |
toCanvas(node) |
Canvas | You need a canvas for further drawing or pixel operations. |
toPixelData(node) |
Pixel data | You need pixel bytes for image processing. |
For options, exact types, and behavior, use the version-matched API documentation in the project README; do not assume an option from another version or library is supported.
What happens during a capture
html-to-image builds an image representation of a DOM node. As described by the project, it clones the node, copies computed styles, embeds web fonts and images, serializes the result into an SVG using <foreignObject>, and can draw that representation to an off-screen canvas for raster output. That process explains why a node that looks correct on screen can still fail during export: the browser must support the rendering path, and the required assets must be accessible for embedding.
PC Slower Than It Used to Be?
A free scan shows the junk files, broken settings and background clutter dragging Windows down - then fixes them in one click.Free scan · Windows 10 & 11Crashes, No Sound, or Screen Glitches?
Random freezes, missing sound and display glitches usually trace back to one bad driver. Find and replace yours safely.Free scan · under a minuteThe README requires Promise and SVG <foreignObject> support and says Internet Explorer is unsupported because it lacks the latter. It describes testing in Chrome, Firefox, and Safari, but its browser-version statements are historical and should not be read as current version guarantees. Test the actual browsers and pages your users need.
Rank #4
- Word-first 16K Pressure Levels: The upgraded stylus features 16,384 levels of pressure sensitivity and supports up to 60 degrees of tilt, delivering smoother lines and shading for a natural drawing experience. With no battery or charging needed, it operates like a real pen, making it easy for beginners to create effortlessly. This functionality helps novice artists develop their skills and explore their creativity without the intimidation of complex tools
- Designed for Beginners: This drawing pad desinged with 8 customizable shortcuts for both right and left-hand users, express keys create a highly ergonomic and convenient work platform
- Perfectly Adapted for Android: The XPPen Deco 01 V3 art tablet supports connections with Android devices running version 10.0 and above. It is recommended to download the XPPen Tools Android application, which adapts to your smartphone's screen aspect ratio, ensuring accurate mapping. It also supports mapping on Android screens with different aspect ratios in portrait mode
- Large Drawing Space, Bigger Bold Inspiration: This expansive drawing pad has10 x 6.25-inch helps you break through the limit between shortcut keys and drawing area
- Easy Connectivity for Beginners: The Deco 01 V3 offers USB-C to USB-C connectivity, plus adapters for USB C. This ensures easy connection to various devices, allowing beginner artists to set up quickly and focus on their creativity without compatibility concerns. Whether using a laptop, tablet, or desktop, the Deco 01 V3 provides a seamless experience, making it an ideal choice for those just starting their digital art journey
Fix common capture failures
| Symptom | Likely cause | What to check or change |
|---|---|---|
htmlToImage is undefined, or the method is missing |
The selected file did not load, it exposes a different export, or it is a module rather than a global bundle. | Check the network request and console, inspect the exact artifact’s format and export, and use the matching module or bundle-loading method. Do not assume an npm import creates a global. |
| The capture rejects or cannot include an image or font | A required cross-origin resource cannot be fetched or embedded under the page’s security conditions. | Check the browser console and network panel for blocked or failed resources. Make required assets available in a way the page’s security context permits and retest. A tainted canvas can prevent output. |
| Output is blank or differs from the page | The resource or style needed by the cloned node may not have been applied or embedded as expected. | Wait until the target content, fonts, and images have loaded before calling the export. Test a smaller node and check whether the relevant assets can be fetched. |
| Very large captures fail | Large DOM trees can exceed data URI limits or strain the rendering path. | Capture a smaller section, reduce the amount of content, or use an output flow appropriate to the size. The README specifically cautions about data URI limits for very large trees. |
| It works in one browser but not another | Rendering support and resource handling vary across browsers; the project requires Promise and SVG <foreignObject> support. |
Test in the browsers you support and check the console for the first error. Do not rely on historical browser-version notes as current compatibility guarantees. |
| Intermittent failures on a CDN script | The request may fail, the URL may no longer identify the expected file, or dependent code may run before loading finishes. | Pin the version, handle the script’s load and error events, inspect the HTTP response, and start capture only after successful loading. |
Performance, reliability, and maintenance
There is no named performance benchmark in the project documentation cited here, so do not assume a fixed capture time or a guaranteed maximum node size. Conversion work depends on the rendered content and resources involved; keep captures scoped to the element you need, wait for required assets before capture, and test realistic pages in the browsers that matter to your application.
A version-pinned URL makes the dependency easier to reproduce than an unpinned URL, but it does not remove the need to verify file availability and behavior. For a CDN-loaded page, make the library’s failed-load state visible and avoid silently returning a broken download. For a packaged application, manage updates through your package and build workflow. In either case, test the same output function and content after changing versions.
Data URLs are convenient for a small image display or download link. If your next step needs a binary object, toBlob may fit better; if it needs drawing or pixel access, use the corresponding canvas or pixel-data function. Pick based on the consumer of the output rather than converting everything to a data URL by default.
Free tools Windows power users keep installed
One-click scans. No signup required.
Best Value
- New upgraded version: Battery-free Stylus with 8192 Levels Pressure does not require charging, The report rate of the H420X graphic tablet has increased to 300 PPS, making lines quicker and smoother, and feel like a real pen. The pen also has 2 customizable buttons on the side that allow you to switch between right-clicking and the eraser etc instantly
- Graphic design tablet H420X is only 7mm in thickness and 167g in weight. A slim and compact design with a active area of 4.17x2.6 inches and dimension of 6.77x4.3 inches make it perfect for limited desktop space and easy to carry out when on a trip.
- H420X huion drawing tablet is compatible with Windows 7 or later, Mac OS 10.12 or later, and Android 6.0 or later. Huion H420X drawing pad has good compatibility with most drawing software including Adobe Photoshop, Paint tool sai, Corel Painter, Illustrator, Sketchbook, Manga Studio, Clip Studio Paint, Fireworks, Comic Studio, SAI, Krista, Infinite Stratos, Pixologic ZBrush and other major graphics applications, and more. H420X is NOT compatible with iOS.
- H420X computer graphics tablets also can be used for playing OSU games, signing documents, taking notes, and more. No need to install the driver. Just plug and play!
- The note taking tablet is also easier to handwrite write, edit, and annotate with a stylus for online education, e-learning, remote working, or web conference. HUION H420X also is compatible with XSplit, Zoom, Microsoft Teams, Word, Excel, PowerPoint, OneNote, and more
Or skip the browser setup
If your goal is a screenshot of a rendered website rather than a client-side export of a DOM node inside your own page, ScreenshotNeo can return an image or PDF from one GET request. For example, this cURL request saves a WebP screenshot of Stripe; replace the URL and API key with your own values. See the ScreenshotNeo documentation for request options and response details.
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp
- Cookie and consent banners, newsletter popups, and chat widgets are removed before the shot; each cleanup step can be turned off.
- Bot checks or CAPTCHAs, blank pages, timeouts, failed loads, and cache hits are not billed. Response headers identify the page verdict and billing outcome.
- An MCP server provides
take_screenshot,get_page_info, andcapture_pdftools for AI agents and MCP clients. - The Free plan includes 1,000 screenshots per month with no card required; paid plans start at $5 for 3,000 screenshots.
Sign up for ScreenshotNeo and get 1,000 free screenshots a month with no card.
Frequently Asked Questions
Does loading the CDN script automatically define a variable named htmlToImage?
Not necessarily. The project README does not guarantee that global name for all CDN artifacts, so check the exact file’s format and export before calling it.
Can html-to-image capture a whole webpage?
Its documented API takes a DOM node. To capture the rendered page, select the page element you intend to export; very large DOM trees can encounter data URI limits.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
Does html-to-image make a server-side screenshot?
No. It renders a DOM node in the browser using SVG and canvas-related browser capabilities; a server-side website screenshot is a different workflow.
Quick Recap
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.




