Skip to content

perf(docs): drop mermaid-vendor from preload, coalesce lucide chunks#1689

Merged
yannickmonney merged 1 commit into
mainfrom
perf/docs-cold-load
May 8, 2026
Merged

perf(docs): drop mermaid-vendor from preload, coalesce lucide chunks#1689
yannickmonney merged 1 commit into
mainfrom
perf/docs-cold-load

Conversation

@yannickmonney

Copy link
Copy Markdown
Contributor

Summary

Cuts the docs cold-load payload by ~60% (from ~1.2 MB compressed to ~430 KB) on pages that don't use Mermaid diagrams.

Measured on the live deployment after enabling Caddy compression:

Chunk Gzipped
mermaid-vendor 719 KB
main entry 257 KB
react-vendor 56 KB
markdown-vendor 46 KB
i18n-vendor 29 KB
router-vendor 26 KB
radix-vendor 12 KB
total 1.17 MB

mermaid-vendor alone is over half the cold load. Removing it gets us under 450 KB.

Changes

1. Strip mermaid-vendor from the preload graph

The Mermaid wrapper component already lazy-loads the library via import('mermaid'), so the chunk should only load when a doc page actually contains a mermaid code block. But Rolldown adds dynamic chunks to the entry HTML's <link rel="modulepreload"> list regardless, forcing every cold visit to download mermaid-vendor whether the page uses it or not.

Use build.modulePreload.resolveDependencies to filter mermaid-vendor out of the preload list. The dynamic import still resolves on demand when a diagram renders — net effect: pages without diagrams skip the 719 KB download entirely; pages with diagrams pay the same cost as before.

2. Coalesce lucide-react icons into one chunk

Before this change, each statically-imported lucide icon shipped as its own ~5 KB chunk. The cold-load HTML had ~30 individual <link rel="modulepreload"> lines for them (arrow-left, arrow-right, bot, check, chevron-down, ...). Bundling them into a single lucide-vendor chunk:

  • shortens the critical request waterfall (one chunk instead of 30 streams)
  • compresses better (a single zstd frame > 30 separate ones)
  • keeps the modulepreload list scannable

Pre-PR checklist

  • Ran bun run checknot run by author; please verify locally
  • Updated services/platform/messages/{en,de,fr}.json — N/A (no UI strings changed)
  • Updated /docs/{en,de,fr}/ — N/A (build infra only)
  • Ran bun run --filter @tale/docs lint and bun run --filter @tale/docs testnot run by author; please verify locally
  • Updated README.md and translations — N/A

Test plan

  • On a docs route without a mermaid block (e.g. /docs/): confirm mermaid-vendor-*.js is not in the cold-load network waterfall and is not in the <link rel="modulepreload"> list. Total transferred bytes for the doc HTML + its preloaded chunks should be ~430 KB compressed.
  • On a docs route with a mermaid block: confirm mermaid-vendor-*.js is fetched lazily once the diagram component mounts, and the diagram renders correctly.
  • Confirm only one lucide-vendor-*.js chunk in the asset directory; no individual icon chunks.
  • Confirm no regressions in client-side route navigation (TanStack Router preload on hover/click should still work).

mermaid-vendor is ~700 KB gzipped — by far the largest chunk on the
docs site, accounting for ~60% of the cold-load payload. The Mermaid
wrapper component already loads the library via `import('mermaid')`
(dynamic), so the chunk only needs to load on doc pages that actually
render a `mermaid` code block.

Rolldown adds dynamic chunks to the entry HTML's modulepreload list
regardless, so every cold visit downloads mermaid-vendor whether the
page uses it or not. Use `build.modulePreload.resolveDependencies` to
filter mermaid-vendor out of the preload graph; the dynamic import
still resolves on demand when a diagram renders. Net effect: cold load
drops from ~1.2 MB to ~430 KB on diagram-free pages.

Also bundle `lucide-react` icons into a single `lucide-vendor` chunk.
Before this each statically-imported icon got its own ~5 KB chunk,
producing ~30 modulepreload links and the same number of HTTP/2
streams on cold load. One chunk compresses better and shortens the
critical request waterfall.
@coderabbitai

coderabbitai Bot commented May 8, 2026

Copy link
Copy Markdown
Contributor

Warning

Rate limit exceeded

@yannickmonney has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 15 minutes and 13 seconds before requesting another review.

You’ve run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: b2f406ee-b87d-45fb-8b1f-cec87cd22f67

📥 Commits

Reviewing files that changed from the base of the PR and between 61db4d5 and 99a4a00.

📒 Files selected for processing (1)
  • services/docs/vite.config.ts
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch perf/docs-cold-load

Tip

💬 Introducing Slack Agent: The best way for teams to turn conversations into code.

Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@yannickmonney yannickmonney merged commit b0e97dc into main May 8, 2026
12 checks passed
@yannickmonney yannickmonney deleted the perf/docs-cold-load branch May 8, 2026 13:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant