perf(ui): lazy-load html-to-image and snapDOM

Both are only needed on explicit user actions (export message as image,
capture preview annotation screenshot). Defer them with dynamic import so
~140 KB leaves the eager app-shell graph.

Co-authored-by: Serhii Dziupin <makeittech@users.noreply.github.com>
This commit is contained in:
Cursor Agent
2026-06-26 11:26:11 +00:00
co-authored by Serhii Dziupin
parent 3d27c0a0ca
commit 05dd270a9a
2 changed files with 8 additions and 3 deletions
@@ -33,7 +33,6 @@ import { copyTextToClipboard } from '@/lib/clipboard';
import { useChatSurfaceMode } from '@/components/chat/useChatSurfaceMode';
import { isVSCodeRuntime } from '@/lib/desktop';
import { useRuntimeAPIs } from '@/hooks/useRuntimeAPIs';
import { toPng } from 'html-to-image';
import { toast } from '@/components/ui';
import { Icon } from "@/components/icon/Icon";
import { formatTimestampForDisplay } from './timeFormat';
@@ -1455,6 +1454,9 @@ const AssistantMessageBody = React.memo(({
wrapper.appendChild(clone);
document.body.appendChild(wrapper);
// Lazy-load html-to-image: only needed when the user exports a
// message as an image, so keep it out of the eager app shell.
const { toPng } = await import('html-to-image');
const dataUrl = await toPng(wrapper, {
quality: 1,
pixelRatio: 2,