perf: lazy-load heavy routes, on-demand highlight.js, and optimize first-load UX

Closed
MA
6mo ago
+900-862

Summary

  • Route-level code splitting: lazy-load Docs (13 kB), Playground (17 kB), and Embed route components via TanStack Router .lazy.tsx files
  • highlight.js (66 kB JS + 2 kB CSS) loaded dynamically only in the embed route, removed from global bundle
  • Filled in missing manifest.json name, short_name, and description for PWA install
  • Added preconnect/dns-prefetch hints for unpkg.com CDN
  • Added top loading bar animation during route transitions
  • DevTools panels now dynamic imports (tree-shaken in production)
  • Removed unused jsdom and @testing-library/dom dependencies
  • Build target set to esnext for smaller modern-browser output

Test plan

  • pnpm validate passes (lint + check + test + test:artifacts + build)
  • 19 package tests + 21 site tests all pass
  • Build produces separate lazy chunks for Docs, Playground, and Embed routes
  • hljs CSS chunk only loaded for embed route

šŸ¤– Generated with Claude Code


Summary by cubic

Speeds up first load by lazy-loading Docs, Playground, and Embed routes and loading highlight.js only when needed. Also adds a small loading bar during route transitions and improves PWA metadata.

  • Performance

    • Route-level code splitting via .lazy.tsx for Docs, Playground, and Embed.
    • Load highlight.js (66 kB JS + 2 kB CSS) only on the embed route; removed from global bundle.
    • DevTools panels now dynamic imports in dev; tree-shaken in production.
    • Added preconnect/dns-prefetch for https://unpkg.com.
    • Build target set to esnext with CSS minification for smaller modern bundles.
    • Removed unused deps: jsdom, @testing-library/dom.
  • UX

    • Added a thin top loading bar during route transitions.
    • PWA manifest now includes name, short_name, and description.