Skip to content

perf(chatbot): lazy-load via next/dynamic + convert (marketing) layout to RSC #39

Description

@abdout

Severity

P1 — Performance

Context

`src/app/[lang]/(marketing)/layout.tsx` was `"use client"` because it held a `useRef` for the chatbot's imperative `openChat()` method. Investigation showed the `onChatClick` prop was drilled through 4 layers (`layout → SiteHeader → SiteHeaderClient → RightActions`) but never actually invoked — `RightActions` accepts the prop and ignores it. `MobileHeader` doesn't even receive it. So the entire prop chain was dead plumbing keeping the layout client-side for nothing.

Fix

  • Drop dead `onChatClick` plumbing across 4 files
  • Convert `(marketing)/layout.tsx` from client to server component
  • Lazy-load `ChatbotContent` via `next/dynamic` (`ssr: false`) inside a tiny `` client island

Impact

  • All marketing pages (`/`, `/pricing`, `/service`) become RSC by default again — chatbot bundle no longer in the marketing critical path
  • Chatbot widget is fetched only when needed; reduces initial JS payload and TTI
  • Honors `PERFORMANCE.md`'s claim of "lazy loading of chat window" which was actually unimplemented

Acceptance criteria

  • `(marketing)/layout.tsx` has no `"use client"` directive
  • Network tab shows chatbot chunk loading after initial page render, not in critical path
  • Chatbot still opens via its in-page button on `/` and `/pricing`
  • No `onChatClick` references anywhere in src/

Reference

Plan: PR-13.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions