DriversRecommendedOutdated drivers can make a good PC feel brokenScan driver issues before chasing fixes manually.Scan NowOctober DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsClean PCRecommendedOne scan can reveal what keeps slowing WindowsLook for cleanup and repair opportunities.Run Scan×
Skip to content
html2canvas

How to Prevent html2pdf from Freezing the UI

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

The reliable fix is to reduce the work done in one browser task. html2pdf.js captures a DOM element with html2canvas, rasterizes it, and passes the result to jsPDF. Its promise-based Worker chain sequences those stages, but it does not move CPU-heavy layout, painting, image decoding, encoding, or PDF assembly off the main thread. A large or complex export can therefore leave too little time for input and rendering.

Start by measuring the export, shrink the capture surface, tune canvas and image settings, make page breaks explicit, and split long documents into sections with real browser yields. For exceptionally heavy jobs, design a worker-compatible or server-side pipeline rather than assuming that wrapping html2pdf() in an async function makes it non-blocking.

Why html2pdf makes the page unresponsive

In a normal export, the browser must clone or inspect the selected DOM, calculate styles and layout, load and decode images, paint a canvas, encode that canvas, assemble PDF pages, and save the resulting file. Those operations compete with pointer events, keyboard input, animation, and screen painting on the main event loop.

The documented html2pdf Worker API is useful for ordering prerequisites and reporting a chain of work. A promise or async function, however, is not a new thread. If a stage performs long synchronous work, the browser cannot process another task until that stage returns.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
#1 Best Overall
Sale
Philips 24 Inch Computer Monitor FHD 100Hz VA VESA Flicker-Free, 241V8LB
  • CRISP CLARITY: This 23.8″ Philips V line monitor delivers crisp Full HD 1920x1080 visuals. Enjoy movies, shows and videos with remarkable detail
  • INCREDIBLE CONTRAST: The VA panel produces brighter whites and deeper blacks. You get true-to-life images and more gradients with 16.7 million colors
  • THE PERFECT VIEW: The 178/178 degree extra wide viewing angle prevents the shifting of colors when viewed from an offset angle, so you always get consistent colors
  • WORK SEAMLESSLY: This sleek monitor is virtually bezel-free on three sides, so the screen looks even bigger for the viewer. This minimalistic design also allows for seamless multi-monitor setups that enhance your workflow and boost productivity
  • A BETTER READING EXPERIENCE: For busy office workers, EasyRead mode provides a more paper-like experience for when viewing lengthy documents

The visible symptom can be a frozen button, delayed scrolling, an unpainted progress label, or a browser “page is unresponsive” warning. The cause is usually the amount of DOM, pixels, images, page-break analysis, or PDF encoding in a single export—not a missing await.

1. Verify which export stage is expensive

  1. Open your browser’s developer tools and select the Performance panel.
  2. Start a recording, click the export button, wait for the file to finish, then stop recording.
  3. Inspect long scripting tasks, layout and style calculation, rasterization, image decoding, memory pressure, and time spent around the save operation.
  4. Repeat with a deliberately small report. If the small report is responsive, document size or resource complexity is the primary variable.

Do not rely on a universal millisecond threshold: hardware, browser version, fonts, images, and document structure vary. Compare the same report before and after each change, and test on the slowest supported device.

2. Capture less DOM

Pass the smallest stable element to from(). Exporting the application shell also captures navigation, hidden panels, live charts, duplicate responsive layouts, and controls that have no place in the PDF.

const report = document.querySelector('#report');
if (!report) throw new Error('Report element not found');

await html2pdf().set(opt).from(report).save();

Build an export-specific representation when the on-screen view is especially complex. Remove menus, animated elements, carousels, continuously updating charts, and content that is outside the requested report. Render optional sections only when the user selects them. A smaller tree reduces cloning, style calculation, layout, canvas painting, and memory use together.

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

Keep the export DOM bounded

  • Use a fixed report container rather than document.body.
  • Pause animation and video while the snapshot is prepared.
  • Replace interactive widgets with static values.
  • Do not keep both mobile and desktop copies visible in the export clone.
  • Remove off-screen or collapsed content unless it belongs in the PDF.

3. Tune rasterization and image work

html2pdf passes html2canvas options through its configuration. More pixels improve apparent sharpness but increase canvas memory, rasterization time, and encoding work. Begin with a scale appropriate to your output, then raise it only when printed text or diagrams need more detail.

Rank #2
Philips 22 Inch Computer Monitor FHD 100Hz VA VESA Flicker-Free, 221V8LB
  • CRISP CLARITY: This 22 inch class (21.5″ viewable) Philips V line monitor delivers crisp Full HD 1920x1080 visuals. Enjoy movies, shows and videos with remarkable detail
  • 100HZ FAST REFRESH RATE: 100Hz brings your favorite movies and video games to life. Stream, binge, and play effortlessly
  • SMOOTH ACTION WITH ADAPTIVE-SYNC: Adaptive-Sync technology ensures fluid action sequences and rapid response time. Every frame will be rendered smoothly with crystal clarity and without stutter
  • INCREDIBLE CONTRAST: The VA panel produces brighter whites and deeper blacks. You get true-to-life images and more gradients with 16.7 million colors
  • THE PERFECT VIEW: The 178/178 degree extra wide viewing angle prevents the shifting of colors when viewed from an offset angle, so you always get consistent colors
const opt = {
  filename: 'report.pdf',
  image: { type: 'jpeg', quality: 0.85 },
  html2canvas: {
    scale: 1,
    useCORS: true,
    logging: false,
    removeContainer: true
  },
  jsPDF: { unit: 'mm', format: 'a4', orientation: 'portrait' },
  pagebreak: { mode: ['css', 'legacy'] }
};

const source = document.querySelector('#report');
await html2pdf().set(opt).from(source).save();

This is a starting configuration, not a guaranteed optimum. Compare text edges, photographs, transparency, file size, memory use, and page breaks on your target browsers.

Choose an image format deliberately

  • JPEG: useful for photographic pages when lossy compression is acceptable; quality and file size trade against one another.
  • PNG: preferable for lossless edges, diagrams, and transparency, but can produce larger data and more encoding work.
  • Source dimensions: constrain very large images to the size they actually occupy. A hidden, multi-megapixel source can still consume memory during decoding.

Cross-origin images and fonts can fail, wait on a network, or taint a canvas. Configure cross-origin access deliberately, ensure the same CDN and authentication behavior used in production, and treat a missing image as a resource problem rather than repeatedly increasing the canvas scale.

4. Make page breaks explicit

html2pdf supports CSS page-break rules, legacy break markers, explicit before and after selectors, and avoid selectors. Use those capabilities to describe the known structure of a report.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
.report-section {
  break-inside: avoid;
}
.page-start {
  break-before: page;
}

Broad avoid-all behavior can force expensive decisions across a deeply nested, long document. Prefer CSS rules and explicit section boundaries. Apply avoidance to headings, cards, tables, or other units that genuinely must remain together instead of asking the library to avoid breaks everywhere.

5. Split long reports and yield between sections

A single call still occupies the main thread for its entire capture. For a long report, divide the work into stable sections, render each section into the PDF integration you use, update progress, and yield before beginning the next section.

Rank #3
Sale
Dell 24 Monitor - SE2426H - 23.8-inch FHD (1920x1080) 144Hz 1ms Display, in-Plane Switching (IPS) Technology, AMD FreeSync™, TÜV 3-Star 2X HDMI, Tilt
  • Clear visuals. Fluid motion: A 144Hz refresh rate and 1ms MPRT deliver smooth, tear‑free motion across work, gaming, and streaming for clearer, more fluid viewing.
  • Eye comfort: TÜV Rheinland 3‑star* certification reduces harmful blue light while preserving stunning color quality without compromise. *TÜV Rheinland 3-star eye comfort certification.
  • Wide viewing angle: Get consistent views across a wide 178° /178° viewing angle.
  • In-Plane Switching (IPS): See excellent color accuracy and consistency across wide viewing angles with In-plane Switching (IPS) technology.
  • Ultra-thin bezels: Maximize your viewing experience with thin bezels.
const yieldToBrowser = () => new Promise(resolve => setTimeout(resolve, 0));

async function exportSections(sections) {
  for (let i = 0; i < sections.length; i++) {
    await renderSectionIntoPdf(sections[i]);
    const percent = Math.round(((i + 1) / sections.length) * 100);
    document.querySelector('#export-progress').textContent = `${percent}%`;
    await yieldToBrowser();
  }
  await finishAndDownloadPdf();
}

The important detail is the task boundary created by the timer (or an animation-frame boundary). Adding another .then() to one monolithic capture does not force the browser to paint between internal synchronous stages. A section can still be heavy, so choose boundaries that keep each unit bounded and show an honest, estimated progress message.

requestIdleCallback can schedule optional preparation, but it is not available in every browser. If the work is required, provide a timer or animation-frame fallback and a timeout so an idle callback cannot postpone an export indefinitely.

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

6. Decide whether a worker architecture fits

Web Workers run JavaScript on a background thread, which can preserve UI responsiveness for compatible computation. They cannot directly access the page DOM. Consequently, moving an unchanged html2pdf() call into a worker and passing it a live HTMLElement is not a complete solution.

OffscreenCanvas can move compatible canvas rendering into a worker where the target browser supports the features your renderer needs. Support and library compatibility are feature-specific, so verify the actual browser matrix.

A practical worker design

  1. On the main thread, build a clean, bounded export representation.
  2. Send serializable HTML/data or prepared images to the worker.
  3. Perform only worker-compatible raster or PDF operations there.
  4. Send progress messages and the final Blob back to the page.
  5. Keep DOM updates, download initiation, and cancellation controls on the main thread.

This approach has higher implementation cost and may change CSS fidelity, font behavior, or selectable text. If preserving live-DOM styling and selectable text matters more than client-only execution, evaluate a server-side or print-oriented renderer instead of forcing html2pdf into an architecture it was not designed to support.

Rank #4
Samsung 27" Essential S3 (S36GD) Series FHD 1800R Curved Computer Monitor
  • CURVED FOR ENHANCED ENGAGEMENT: An immersive viewing experience with a curved monitor that wraps more closely around your field of vision; It creates a wider view, enhancing depth perception and minimizing peripheral distraction
  • SMOOTH PERFORMANCE FOR SEAMLESS CONTENT: Stay in the action when playing games, watching videos, or working on creative projects; The 100Hz refresh rate reduces lag and motion blur so you don't miss a thing in fast-paced moments¹
  • MORE GAMING POWER: Gain the edge with optimizable game settings; Color and image contrast can be adjusted to see scenes more vividly and spot enemies hiding in the dark; Game Mode adjusts any game to fill the screen so you can view every detail²
  • KEEP IT EASY ON THE EYES: Care for your eyes and stay comfortable, even during long sessions; Advanced eye comfort technology certified by TÜV reduces eye strain by minimizing blue light and reducing irritating screen flicker²
  • INCREASED VERSATILITY: Connect to more; Plug devices straight into your monitor for increased flexibility, making your computing environment even more convenient

Which approach should you choose?

Approach UI responsiveness Live DOM/CSS fidelity Effort Best fit
Smaller DOM and lower capture cost Often improves substantially High for retained content Low Most reports and dashboards
Sectioned export with yields Better between sections; each section can still be heavy Medium to high Medium Long reports with clear boundaries
Worker with compatible rendering Highest potential Depends on serialization and renderer High Very heavy, repeatable exports
Server-side or print-oriented generation UI remains responsive Depends on renderer and CSS support Medium to high, plus infrastructure Large documents or strict production output

Or skip the browser setup

If your goal is a clean image or PDF of a web page rather than a client-side export of your application’s live DOM, ScreenshotNeo provides a one-request screenshot API and an MCP server for AI agents. It removes cookie/consent banners, newsletter popups, and chat widgets before capture; bot checks, blank pages, failed loads, timeouts, and cache hits are not billed, and each response identifies the page verdict and billing status in headers.

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.

Use the documented API options for full-page capture, lazy-loaded images, CSS-selector elements, device presets, custom viewport and retina scale, PDF paper settings, custom CSS or JavaScript, waits, blocked resources, headers, cookies, user agent, authorization, timezone, geolocation, transparent backgrounds, resizing, caching, signed links, asynchronous jobs, bulk capture, and usage reporting. The MCP tools are named take_screenshot, get_page_info, and capture_pdf; they work with Claude, Cursor, and other MCP clients.

One-call examples

See the ScreenshotNeo documentation for authentication and all parameters.

curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp
import requests
r = requests.get("https://api.screenshotneo.com/v1/shot", params={"access_key": "YOUR_API_KEY", "url": "https://stripe.com"}, timeout=90)
r.raise_for_status()
open("shot.webp", "wb").write(r.content)
const q = new URLSearchParams({ access_key: 'YOUR_API_KEY', url: 'https://stripe.com' });
const res = await fetch(`https://api.screenshotneo.com/v1/shot?${q}`);
if (!res.ok) throw new Error(`Screenshot failed: ${res.status}`);
const data = Buffer.from(await res.arrayBuffer());
require('fs').writeFileSync('shot.webp', data);

The Free plan includes 1,000 shots per month without a card. Paid plans start at $5 for 3,000 shots; every feature is available on every plan. Create a free ScreenshotNeo account to try it.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Troubleshooting common failures

The progress label does not update

Cause: the label update is queued behind a monolithic synchronous capture. Fix: split the export, update after each section, and yield with a timer or animation frame.

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

Lowering scale makes the PDF blurry

Cause: fewer canvas pixels are being enlarged in the PDF. Fix: raise scale gradually, reduce source image dimensions, and test the required paper size rather than maximizing scale globally.

Best Value
Sale
Sceptre New 22-Inch Gaming Monitor, FHD 1080p, Up to 144Hz, HDMI, DisplayPort, Built-in Speakers, Machine Black (E225W-FW144 Series, 2026)
  • 【INTEGRATED SPEAKERS】Whether you're at work or in the midst of an intense gaming session, our built-in speakers provide rich and seamless audio, all while keeping your desk clutter-free.
  • 【EASY ON THE EYES】 Protect your eyes and enhance your comfort with Blue-Light Shift technology. This feature reduces harmful blue light emissions from your screen, helping to alleviate eye strain during long hours of use and promoting healthier viewing habits.
  • 【WIDEN YOUR PERSPECTIVE】Our sleek minimal bezel design ensures undivided attention. The nearly bezel-free display seamlessly connects in a dual monitor arrangement, delivering an unobstructed view that lets you focus on more at once, completely distraction-free.

Images are missing or the export waits a long time

Cause: cross-origin restrictions, slow resources, authentication, or image decoding. Fix: verify response headers and credentials, use production-like CDN conditions, and remove unnecessary images from the export.

Page breaks are strange or the export takes much longer after adding avoidance

Cause: broad avoidance rules create expensive layout decisions. Fix: replace global avoidance with targeted CSS, explicit section starts, and a small set of elements that must stay together.

A worker version throws DOM-related errors

Cause: workers cannot read live DOM nodes. Fix: serialize the content or send prepared images, then use a renderer that is explicitly worker-compatible; keep DOM preparation on the main thread.

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

Memory usage spikes or the tab crashes

Cause: an oversized capture surface, high scale, large decoded images, or simultaneous canvases. Fix: export fewer sections at once, lower scale, constrain image dimensions, release temporary canvases, and test on constrained devices.

Frequently Asked Questions

Does adding async to the export function prevent freezing?

No. It sequences promises but does not move synchronous html2canvas or jsPDF work away from the main thread.

Can I pass an HTMLElement directly to a Web Worker?

No. Build serializable data or prepared images on the main thread and send those to worker-compatible code.

Is requestIdleCallback safe for a required export?

Use it only for optional preparation, and provide a timer or animation-frame fallback because browser availability is limited.

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

Should I always use PNG for PDF exports?

No. JPEG can reduce work and size for photographic content; PNG is better when lossless edges or transparency are required.

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.

Leave a Reply

Your email address will not be published. Required fields are marked *

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.

Read next

Recommended PC Tool
Recommended PC Tool
PC Slower Than It Used to Be?Free scan - under a minute
Crashes, No Sound, or Screen Glitches?Free driver scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.