From ecb5855ec7167c717d37f659ea357a45ecac1815 Mon Sep 17 00:00:00 2001 From: BigSimmo <87357024+BigSimmo@users.noreply.github.com> Date: Sat, 18 Jul 2026 15:21:19 +0800 Subject: [PATCH 1/2] perf: lazy-load document pdf viewer --- src/components/DocumentViewer.tsx | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/src/components/DocumentViewer.tsx b/src/components/DocumentViewer.tsx index 05f21b30..d37baa3f 100644 --- a/src/components/DocumentViewer.tsx +++ b/src/components/DocumentViewer.tsx @@ -133,6 +133,34 @@ function PdfPreviewLoading() { ); } +// pdf-canvas-viewer is only needed after a source document has loaded and the +// user is viewing a PDF. Keeping it out of the document route's initial client +// chunk avoids parsing its reader controls for image, text, and download-only +// documents. pdf.js itself remains loaded on demand by that component. +const PdfCanvasViewer = dynamic( + () => import("@/components/document-viewer/pdf-canvas-viewer").then((module) => module.PdfCanvasViewer), + { + ssr: false, + loading: () => , + }, +); +const NativePdfEmbed = dynamic( + () => import("@/components/document-viewer/pdf-canvas-viewer").then((module) => module.NativePdfEmbed), + { ssr: false, loading: () => }, +); + +function PdfPreviewLoading() { + return ( +
+ Loading PDF reader… +
+ ); +} + type PageRow = { id: string; page_number: number; From 5db6cc66ce01e7e70c127ccfb91c9502facf61a7 Mon Sep 17 00:00:00 2001 From: BigSimmo <87357024+BigSimmo@users.noreply.github.com> Date: Sat, 18 Jul 2026 16:06:02 +0800 Subject: [PATCH 2/2] fix: remove duplicate PDF viewer dynamic imports --- src/components/DocumentViewer.tsx | 28 ---------------------------- 1 file changed, 28 deletions(-) diff --git a/src/components/DocumentViewer.tsx b/src/components/DocumentViewer.tsx index d37baa3f..05f21b30 100644 --- a/src/components/DocumentViewer.tsx +++ b/src/components/DocumentViewer.tsx @@ -133,34 +133,6 @@ function PdfPreviewLoading() { ); } -// pdf-canvas-viewer is only needed after a source document has loaded and the -// user is viewing a PDF. Keeping it out of the document route's initial client -// chunk avoids parsing its reader controls for image, text, and download-only -// documents. pdf.js itself remains loaded on demand by that component. -const PdfCanvasViewer = dynamic( - () => import("@/components/document-viewer/pdf-canvas-viewer").then((module) => module.PdfCanvasViewer), - { - ssr: false, - loading: () => , - }, -); -const NativePdfEmbed = dynamic( - () => import("@/components/document-viewer/pdf-canvas-viewer").then((module) => module.NativePdfEmbed), - { ssr: false, loading: () => }, -); - -function PdfPreviewLoading() { - return ( -
- Loading PDF reader… -
- ); -} - type PageRow = { id: string; page_number: number;