Skip to content

perf: preload API specs fetch in SSR head#146

Open
rsbh wants to merge 1 commit into
mainfrom
worktree-keen-herding-steele
Open

perf: preload API specs fetch in SSR head#146
rsbh wants to merge 1 commit into
mainfrom
worktree-keen-herding-steele

Conversation

@rsbh
Copy link
Copy Markdown
Member

@rsbh rsbh commented Jun 3, 2026

Summary

  • Add <link rel="preload" as="fetch"> for /api/specs in SSR <head> on API routes
  • Browser starts fetching specs immediately while parsing HTML, overlapping with JS bundle download
  • Reduces perceived load time on API page first load

Test plan

  • Build passes (bun run build:cli)
  • Dev server renders preload link in API page HTML
  • Non-API pages unaffected (preload only added when isApiRoute)
  • Verify in browser Network tab that /api/specs fetch starts before JS execution

🤖 Generated with Claude Code

Browser starts fetching /api/specs as soon as <head> is parsed,
overlapping with JS bundle download instead of waiting for it.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@vercel
Copy link
Copy Markdown

vercel Bot commented Jun 3, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
chronicle Ready Ready Preview, Comment Jun 3, 2026 11:06am

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Jun 3, 2026

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: dfc921b4-17b7-4901-a9c6-b6a3a1692647

📥 Commits

Reviewing files that changed from the base of the PR and between 86cbba0 and 57a4bdd.

📒 Files selected for processing (1)
  • packages/chronicle/src/server/entry-server.tsx

📝 Walkthrough

Summary by CodeRabbit

  • Chores
    • Optimized API specification loading performance through resource preloading for API routes, reducing initial load times.

Walkthrough

This PR adds a preload link for API specifications in the SSR entry point's head. When a route is an API route and has a version directory, the preload targets the versioned specs endpoint (/api/specs?version=...), otherwise it preloads the default specs endpoint.

Changes

API Specs Preload

Layer / File(s) Summary
API specs preload link injection
packages/chronicle/src/server/entry-server.tsx
The SSR entry head conditionally renders a <link rel="preload" as="fetch"> element for API specs, using a versioned URL when route.version.dir is present, otherwise using the default specs endpoint.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~5 minutes

Suggested reviewers

  • rohilsurana
  • paanSinghCoder
  • rohanchkrabrty
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately and concisely describes the main change: adding a preload link for API specs in the SSR head as a performance optimization.
Description check ✅ Passed The description is directly related to the changeset, clearly explaining the purpose, implementation details, and test plan for the preload optimization.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch worktree-keen-herding-steele

Warning

Review ran into problems

🔥 Problems

Git: Failed to clone repository. Please run the @coderabbitai full review command to re-trigger a full review. If the issue persists, set path_filters to include or exclude specific files.


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.

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