perf: remove TipTap/ProseMirror from client bundle, lazy-load below-fold sections
TipTap (ProseMirror) was causing: - chunks 1007 (85 KiB) and 3207 (58 KiB) in the initial bundle - Array.prototype.at/flat/flatMap, Object.fromEntries/hasOwn polyfills (ProseMirror bundles core-js for these — the 12 KiB legacy JS flag) - 2+ seconds of main thread blocking on mobile Fix: move HTML conversion to the server (API route) and pass the resulting HTML string to the client, eliminating the need to import richTextToSafeHtml (and transitively TipTap) in any client component. Changes: - app/api/content/page/route.ts: call richTextToSafeHtml server-side, add html: string to response alongside existing content - app/components/RichTextClient.tsx: accept html string, remove all TipTap imports — TipTap/ProseMirror now has zero client bundle cost - app/components/About.tsx, Contact.tsx: use cmsHtml from API - app/legal-notice/page.tsx, privacy-policy/page.tsx: same - app/components/ClientWrappers.tsx: change static imports of About, Projects, Contact, Footer to next/dynamic so their JS is in separate lazy-loaded chunks, not in the initial bundle Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -6,10 +6,14 @@
|
||||
*/
|
||||
|
||||
import { NextIntlClientProvider } from 'next-intl';
|
||||
import About from './About';
|
||||
import Projects from './Projects';
|
||||
import Contact from './Contact';
|
||||
import Footer from './Footer';
|
||||
import dynamic from 'next/dynamic';
|
||||
|
||||
// Lazy-load below-fold components so their JS doesn't block initial paint / LCP.
|
||||
// SSR stays on (default) so content is in the initial HTML for SEO.
|
||||
const About = dynamic(() => import('./About'));
|
||||
const Projects = dynamic(() => import('./Projects'));
|
||||
const Contact = dynamic(() => import('./Contact'));
|
||||
const Footer = dynamic(() => import('./Footer'));
|
||||
import type {
|
||||
AboutTranslations,
|
||||
ProjectsTranslations,
|
||||
|
||||
Reference in New Issue
Block a user