Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

The html2canvas message Unable to load image undefined is a symptom, not a single documented diagnosis. Start by identifying the image or CSS background that html2canvas is trying to read. Verify that its URL exists and is valid, inspect the browser’s Network result, and then address origin and browser-policy restrictions. Only increase imageTimeout when the URL is valid but genuinely slow.

What the error actually tells you

html2canvas rebuilds a representation of the captured DOM; it is not a native screenshot of the browser’s final pixels. During that process it reads images referenced by <img> elements, CSS background-image declarations, and other resources in the captured subtree. If one reference resolves to no URL, the literal string undefined, a failed request, or an image the browser will not let the library read, the console can show this message.

The wording alone does not identify the cause in your application. The older Stack Overflow report that uses this exact phrase does not reveal where its undefined value originated. Treat it as a starting point for diagnosis, not proof that every case has the same fix.

Find the image reference first

Inspect image elements

In DevTools Console, inspect the subtree you pass to html2canvas:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
#1 Best Overall
Sale
Kodak PIXPRO FZ45 Digital Camera, 16MP Point & Shoot (Black)
  • 16MP Sensor: Captures detailed photos with a CMOS sensor for everyday shooting
  • Optical Zoom: 4x optical zoom with a 27mm wide angle lens for flexible framing indoors or outdoors
  • Full HD Video: Records 1080p video for travel clips, family moments, or simple vlogging
  • Memory Support: Works with Class 10 SD, SDHC, or SDXC cards up to 512GB
  • LCD Screen and Battery: 2.7in LCD screen with 2 AA alkaline batteries for convenient on-the-go use
const root = document.querySelector('#capture');
[...root.querySelectorAll('img')].map((img) => ({
  src: img.getAttribute('src'),
  currentSrc: img.currentSrc,
  complete: img.complete,
  naturalWidth: img.naturalWidth,
  naturalHeight: img.naturalHeight
}));

Look for a missing src, an empty string, the literal text undefined, a relative URL that resolves unexpectedly, or naturalWidth: 0 after loading should have completed. Check currentSrc, because responsive images may use srcset rather than the value you expect in src.

Inspect CSS backgrounds

An apparently image-free component can contain a background image. In the Elements panel, search the captured subtree for background-image. In code, inspect computed styles:

for (const el of root.querySelectorAll('*')) {
  const value = getComputedStyle(el).backgroundImage;
  if (value && value !== 'none') console.log(el, value);
}

Also check pseudo-elements, inline styles, generated content, and framework data that builds URLs at render time. A template expression that runs before its image data arrives can produce url(undefined) even when the final component usually displays correctly.

Confirm the value before calling html2canvas

const image = document.querySelector('#hero');
if (!image?.src || image.src.endsWith('/undefined')) {
  throw new Error(`Invalid image URL: ${image?.src}`);
}

Fix the data flow at its source rather than hiding the warning. Supply a real fallback image, delay rendering until the URL is available, or remove the image reference when no asset exists.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Check the request in the browser

  1. Open DevTools and select the Network tab.
  2. Filter by Img (and inspect CSS or “Other” requests if the asset is a background).
  3. Reload the page and reproduce the capture.
  4. Open the failed request and record its status, final URL, response headers, redirect chain, and timing.

A 404 or 410 means the path is wrong or the asset was removed. A 401 or 403 commonly indicates authentication, a hot-link rule, or a signed URL that expired. A redirect can lead to an HTML login page instead of an image. A request that never completes may be blocked by a service worker, an extension, a network policy, or an unresponsive origin. Open the final URL directly in a new tab where possible; confirm that it returns an image and not an error document.

Do this check in the same browser context as the capture. A URL that works in a new tab can still fail when requested from a different origin, with different cookies, or without an authorization header.

Rank #2
Sale
Kodak PIXPRO FZ55-BK 16MP CMOS Sensor Camera 5X Optical Zoom 28mm Wide
  • 16MP Sensor: Captures detailed photos with a CMOS sensor for everyday shooting
  • Optical Zoom: 5x optical zoom with a 28mm wide angle lens for flexible framing indoors or outdoors
  • Full HD Video: Records 1080p video for travel clips, family moments, or simple vlogging
  • Memory Support: Works with Class 10 SD, SDHC, or SDXC cards up to 512GB
  • LCD Screen and Battery: 2.7in LCD screen and a rechargeable lithium-ion battery for on-the-go use

Understand same-origin and CORS behavior

html2canvas documents that images need to be on the page’s origin or be made available through a configured proxy. Cross-origin images can taint the canvas. With the documented default allowTaint: false, html2canvas will not draw an image that would taint it. The project explicitly states that it does not get around content-policy restrictions imposed by the browser.

The documented defaults are:

Option Default What it means
allowTaint false Do not draw images that would taint the canvas.
useCORS false Do not request cross-origin images with CORS mode unless enabled.
proxy null No image proxy is configured.
imageTimeout 15000 ms Stop waiting after 15 seconds unless changed.

Verify these values against the html2canvas version installed by your application; documentation indexed several years ago may not describe every behavior of a newer release.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Choose the correct cross-origin fix

Use CORS when the image host is under your control

Set useCORS: true only when the image server returns an appropriate Access-Control-Allow-Origin response for your page. The server must send that header on the image response, including through redirects where applicable. Client-side JavaScript cannot manufacture a missing response header.

html2canvas(document.querySelector('#capture'), {
  useCORS: true,
  allowTaint: false
}).then(canvas => {
  document.body.appendChild(canvas);
});

If credentials are required, configure the server and request mode consistently. Do not assume that adding useCORS bypasses authentication or a restrictive policy.

Use a server-side proxy when CORS is unavailable

A proxy fetches the image from the server side and serves it from an origin your page can read. html2canvas requires an actual proxy implementation; placing an arbitrary URL in the option does not remove browser restrictions. Your proxy must validate destinations, prevent server-side request forgery, enforce size and content-type limits, handle redirects safely, and avoid leaking private image URLs or credentials.

html2canvas(document.querySelector('#capture'), {
  proxy: '/image-proxy',
  allowTaint: false
});

Test the proxy response in DevTools. It should return the image bytes with a suitable content type and without an authentication challenge. If your application cannot safely operate such a service, keep the asset same-origin or have the image host add CORS support.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #3
Sale
Digital Camera, Latest FHD 1080P Digital Camera for Teens with SD Card Anti Shake Point and Shoot Cameras Portable 16X Zoom Compact Small Cameras for Kids Boys Girls Seniors with Wrist Strap
  • Latest Digital Camera Built-in Fill Light : This compact digital camera is paired with a powerful CMOS processor and image stabilization to help you take & record the most exciting moments in 44 MP quality images & FHD 1080P quality videos anywhere, anytime. Plus, there is also a built-in fill light to help you take high quality pictures even in low light&dark settings, making this the perfect camera for all indoors/outdoors situations.
  • Long-Lasting Battery Life & 16X Digital Zoom :This point and shoot camera will retain its battery charge even after long use. The controls and functions are easy to operate making this the perfect choice for children, teens and younger. This kids camera supports 16x digital zoom, you can zoom in or out the subject by pressing the W/T button for taking still photos to zoom in or out on distant objects and capture all the details you need.
  • Multifunctional & Portable Digital Camera: This cheap digital camera is slim enough to fit in your pocket. You'll easily be able to take it with you on all your indoor/outdoor activities and adventures and ideal for beginners, children and teenagers. This kids digital camera is equipped with 20 filters, anti-shaking, self-timer, continuous shooting, date stamp, time-lapse recording, smile capture, internal MIC and speaker (recording sound videos), great for your daily photography needs.
  • WEBCAM & PAUSE FUNCTION : More than just a FHD 1080p digital camera, it also works as a webcam for video calls and vlogging. Connect the camera to the computer, press shutter and power button at the same time and the camera will automatically turn on webcam mode for all your video calling and live streaming needs. The pause function allows you to pause when seeing playback videos.
  • A Must Have Photography Device : This digital camera with SD card made from high-quality materials, this retro camera is safe and durable. Perfect for all ages to develop & improve their photographic abilities and observation skills. Our dedicated and experienced 24/7 support team is available for all after purchase troubleshooting, questions and technical help.

Do not treat allowTaint: true as a universal repair

Allowing tainted content can prevent certain reads from succeeding and can make canvas export operations fail. It does not make an invalid URL valid, and it does not override browser content policy. Use it only when you understand the resulting limitations and do not need to read or export the canvas in a way the browser forbids.

Use timeouts only for valid, slow images

The documented imageTimeout default is 15,000 milliseconds. Increasing it can help when the request is valid and eventually completes:

html2canvas(document.querySelector('#capture'), {
  imageTimeout: 30000
});

Setting imageTimeout: 0 disables the timeout according to the options documentation. That can leave a capture waiting indefinitely when an origin is down, so prefer fixing upstream latency and retaining a bounded timeout in production. A longer wait cannot repair a missing URL, a 404, a denied CORS response, or a CAPTCHA page.

Isolate the failing element

Temporarily remove suspect images or exclude them from the clone. html2canvas supports an ignoreElements callback and the data-html2canvas-ignore attribute.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
html2canvas(document.querySelector('#capture'), {
  ignoreElements: (element) => element.matches('.live-chat, .remote-ad')
});
<img src="https://cdn.example.test/photo.jpg"
     data-html2canvas-ignore="true" alt="">

If the capture succeeds, restore excluded elements in groups until the warning returns. This binary-search approach identifies the responsible subtree quickly. Replace a problematic remote image with a same-origin, known-good test asset to distinguish application data errors from origin policy errors.

A reliable capture pattern

import html2canvas from 'html2canvas';

async function capture() {
  const element = document.querySelector('#capture');
  if (!element) throw new Error('Capture element not found');

  await document.fonts?.ready;
  const images = [...element.querySelectorAll('img')];
  await Promise.all(images.map((img) => {
    if (img.complete) return Promise.resolve();
    return new Promise((resolve) => {
      img.addEventListener('load', resolve, { once: true });
      img.addEventListener('error', resolve, { once: true });
    });
  }));

  const canvas = await html2canvas(element, {
    useCORS: true,
    allowTaint: false,
    imageTimeout: 15000,
    backgroundColor: '#ffffff'
  });
  return canvas.toDataURL('image/png');
}

capture().then((dataUrl) => {
  const link = document.createElement('a');
  link.href = dataUrl;
  link.download = 'capture.png';
  link.click();
}).catch(console.error);

Waiting for fonts and image events reduces races, but it cannot change a server response or browser policy. Keep logging the URL and Network outcome for every image that remains unresolved.

Rank #4
Kodak PIXPRO FZ55-RD 16MP Camera 5X Optical Zoom 28mm Wide Angle 1080p
  • 16MP Sensor: Captures detailed photos with a CMOS sensor for everyday shooting
  • Optical Zoom: 5x optical zoom with a 28mm wide angle lens for flexible framing indoors or outdoors
  • Full HD Video: Records 1080p video for travel clips, family moments, or simple vlogging
  • Memory Support: Works with Class 10 SD, SDHC, or SDXC cards up to 512GB
  • LCD Screen and Battery: 2.7in LCD screen and a rechargeable lithium-ion battery for on-the-go use
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Common symptoms and targeted fixes

Symptom Likely cause Fix
Console mentions undefined; no request appears Missing data, empty src, or invalid CSS URL Log src, currentSrc, and computed backgrounds; fix URL construction.
Request is 404 Wrong path, deployment base URL, or deleted asset Correct the path and verify the built production URL.
Request is 401/403 Auth, expiring signature, or hot-link protection Provide an authorized same-origin route, public asset, or controlled proxy.
Request succeeds but canvas omits image Cross-origin response lacks CORS headers Enable server CORS and useCORS, or use a secure proxy.
Failure occurs after 15 seconds Slow or stalled valid request Fix upstream performance or increase imageTimeout deliberately.
Capture works after excluding one node That node contains the failing image, ad, or widget Replace, proxy, or permanently ignore the resource.

Production reliability and security checklist

  • Record the html2canvas version, browser, options, captured selector, and failing URL.
  • Test with the same authentication state and deployment origin your users have.
  • Use deterministic, cacheable image URLs where possible; avoid expiring signatures shorter than the capture window.
  • Set a finite timeout and report failures rather than silently producing incomplete images.
  • If you operate a proxy, restrict allowed hosts, block private network ranges, cap response size, validate content types, and strip unnecessary credentials.
  • Expect third-party ads, chat widgets, consent tools, and bot challenges to change independently of your code.

Or skip the browser setup

For server-side captures, ScreenshotNeo returns a PNG, JPEG, WebP, or PDF from one request. It accepts cookie and consent banners before capture and removes more than 60 known consent platforms, newsletter popups, and chat widgets; each cleanup step can be disabled. Bot checks, blank pages, timeouts, failed loads, and cache hits are not billed, and response headers identify the page verdict and billing status.

cURL (see the ScreenshotNeo documentation):

curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp

Python:

import requests
r = requests.get("https://api.screenshotneo.com/v1/shot", params={"access_key": "YOUR_API_KEY", "url": "https://stripe.com"}, timeout=90)
open("shot.webp", "wb").write(r.content)

Node.js:

const q = new URLSearchParams({ access_key: 'YOUR_API_KEY', url: 'https://stripe.com' });
const res = await fetch(`https://api.screenshotneo.com/v1/shot?${q}`);

ScreenshotNeo also provides an MCP server with take_screenshot, get_page_info, and capture_pdf for Claude, Cursor, and other MCP clients. Every plan includes its options, including full-page lazy-image loading, CSS-selector element capture, device and retina settings, custom CSS and JavaScript, waits, request blocking, headers and cookies, timezone and geolocation, signed links, asynchronous webhooks, bulk capture of up to 100 URLs per call, and a usage API. The free plan includes 1,000 screenshots per month with no card; paid plans start at $5 for 3,000 shots. Sign up free for ScreenshotNeo.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

FAQ

Can I fix this only by changing JavaScript options?

No. Options can select a supported loading route, but they cannot correct an undefined URL or override a browser policy enforced by the image server and the browser.

Why does the page display the image but html2canvas cannot?

Displaying an image and reading it into a canvas have different security requirements. A cross-origin image may render normally while remaining unreadable to canvas without an appropriate CORS response.

Should I disable image loading?

Only as a diagnostic or intentional design choice. Excluding an image proves where the failure is, but the resulting capture is incomplete unless you replace the asset or provide a permitted loading path.

Frequently Asked Questions

Does html2canvas capture a screenshot exactly like the browser?

No. It reconstructs the captured DOM and resources, so unsupported CSS, external assets, and browser policies can produce a result different from the visible page.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Is a 15-second timeout a server limit?

No. It is html2canvas’s documented image-loading timeout default. It applies to the library’s wait for an image, not to the origin server’s own timeout policy.

Quick Recap

SaleBestseller No. 1
Kodak PIXPRO FZ45 Digital Camera, 16MP Point & Shoot (Black)
Kodak PIXPRO FZ45 Digital Camera, 16MP Point & Shoot (Black)
16MP Sensor: Captures detailed photos with a CMOS sensor for everyday shooting; Full HD Video: Records 1080p video for travel clips, family moments, or simple vlogging
$99.99
SaleBestseller No. 2
Kodak PIXPRO FZ55-BK 16MP CMOS Sensor Camera 5X Optical Zoom 28mm Wide
Kodak PIXPRO FZ55-BK 16MP CMOS Sensor Camera 5X Optical Zoom 28mm Wide
16MP Sensor: Captures detailed photos with a CMOS sensor for everyday shooting; Full HD Video: Records 1080p video for travel clips, family moments, or simple vlogging
$139.99
Bestseller No. 4
Kodak PIXPRO FZ55-RD 16MP Camera 5X Optical Zoom 28mm Wide Angle 1080p
Kodak PIXPRO FZ55-RD 16MP Camera 5X Optical Zoom 28mm Wide Angle 1080p
16MP Sensor: Captures detailed photos with a CMOS sensor for everyday shooting; Full HD Video: Records 1080p video for travel clips, family moments, or simple vlogging
$139.99

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.