Skip to content

Add route-level code splitting with React.lazy() #9

Description

@satsdisco

Summary

All route components are eagerly imported in App.tsx. The main JS chunk is 493KB (169KB gzipped). Since most users land on either the Press (reading) or Editor (writing) view, we should lazy-load routes.

Implementation

const Press = React.lazy(() => import("./components/Press"))
const ArticleReader = React.lazy(() => import("./components/ArticleReader"))
const Settings = React.lazy(() => import("./components/Settings"))
const AuthCallback = React.lazy(() => import("./components/AuthCallback"))
  • Wrap routes in <Suspense fallback={<LoadingSkeleton />}>
  • Editor can stay eagerly loaded (primary use case)
  • Tiptap chunk (395KB) only loads when editor mounts

Acceptance Criteria

  • Initial load JS reduced by at least 30%
  • Route transitions show loading state (not white flash)
  • No regression in navigation or deep links
  • Chunk error handler in index.html still works

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions