// Current: PDF.js on main thread with its internal worker import * as pdfjsLib from "pdfjs-dist"; import pdfWorker from "pdfjs-dist/build/pdf.worker.min.mjs?url"; // PDF.js handles rendering/decoding in its own worker pdfjsLib.GlobalWorkerOptions.workerSrc = pdfWorker; // Our parsing logic runs on main thread export async function extractPdfText(file: File): Promise { const buffer = await file.arrayBuffer(); const pdf = await pdfjsLib.getDocument({ data: buffer }).promise; // ... text extraction logic } ``` Why This Works for Us Now: - File sizes are small - Typical documents are 1-3 pages (~1.5MB), parsing takes 120-200ms - Infrequent uploads - Users upload documents intentionally, expect brief processing - Acceptable UX - brief parsing delays were rarely noticeable on modern devices - Reduced complexity - No worker lifecycle management, simpler debugging, faster iteration - PDF.js internal worker - Already handles heavy lifting (rendering, font decoding) off main thread Measured Performance (Production): ``` Document Size: 1.5MB (3 pages) Parse Time: 120ms Minor responsiveness dips: ~100 to 150ms User perception: Near-instant