rescript-lang / rescript-lang/rescript-lang.org
Improve homepage performance and route payload boundaries
Nobody has claimed this yet.
- Dominant language
- MDX
- Stars
- 1.9k
- Forks
- 260
- Avg merge
- 3d 9h
- Merged PRs (30d)
- 17
Description
Context
The prerendered homepage currently inherits JavaScript and CSS owned by the React Router root route even when those resources are only needed by content, search, or playground routes. The homepage also has opportunities to reduce DOM complexity, effects, and image transfer costs.
DocsRoot is the React Router root route and should retain only resources genuinely shared by every route. Route-specific resources should move into matched child layouts or lazy boundaries.
Current baseline
- 22 initial JavaScript assets, approximately 275 KB gzip
- Shared root chunk approximately 125 KB gzip
- Initial CSS approximately 14.8 KB gzip
- 419 body elements
- 63 homepage images
- 61 images without width; all 63 without height
- No responsive picture or srcset output
These are starting measurements rather than final budgets. Deterministic build metrics should be recorded and ratcheted down as the work lands.
Proposed PR stack
- Add homepage performance guardrails: production Playwright coverage, stronger Vitest behavior coverage, and deterministic bundle/DOM/image reporting (#1355)
- Split the large homepage module into small, focused components and remove unused Markdown imports, unnecessary state, and redundant markup (#1358)
- Improve font loading with self-hosted Red Hat Mono and homepage-only preloads for Inter 400/600/700 and Red Hat Mono 700 (#1360)
- Refactor clipboard and gallery interactions to reduce effects and imperative DOM work (#1362)
- Add responsive-image Vite integration, tuned source sets, and intrinsic dimensions for all homepage images and videos
- Lazy-load DocSearch, search-insights, and search-specific CSS after activation
- Precompute homepage code highlighting during prerendering
- Move syntax registration out of the root route and make content highlighting dependencies explicit
- Add pathless landing, content, and playground layouts and split Tailwind/CSS ownership by matched route
- Add React Compiler in annotation mode and incrementally opt cleaned homepage modules into compilation
Implementation notes
Tests and measurements
Playwright is already installed and Vitest already uses its browser provider. Add a standalone Playwright configuration for tests against the production/prerendered artifact while keeping Vitest as the component and integration layer.
Test direct loading and client navigation between the homepage, documentation, and playground routes. Assert hydration without page or console errors, preserve critical links and interactions, and avoid timing-based Lighthouse gates in CI.
Root and syntax payloads
The root route currently owns global styles, Highlight.js language registration, the navbar, and the eager search dependency. The homepage also performs runtime highlighting for two static examples and carries an unused Markdown component dependency.
Move fixed homepage highlighting into its prerender loader. Scope content highlighting explicitly so the homepage does not preload Highlight.js core, the full language set, Markdown, or MarkdownComponents.
Route CSS
Split styles into shared foundation, landing, content, playground, and lazy search inputs. Use pathless layouts and route links exports to associate resources with matched routes. Ensure Tailwind theme/preflight is emitted once, and verify cascade order and flashes during client navigation.
Images
Use @responsive-image/react, @responsive-image/vite-plugin, and @responsive-image/core for the five raster placements that benefit from adaptive variants. Keep small illustrations, icons, logos, and video posters simple, but give every image and video accurate intrinsic dimensions and appropriate loading priority.
Measure the responsive-image React runtime because the supported component currently uses an effect per mounted image.
React Compiler
Configure annotation mode targeting React 19 and opt in only homepage modules with stable component boundaries and cleaned-up effects. Keep existing manual memoization during the initial rollout.
Acceptance criteria
- Every layer passes ReScript compilation, Vitest, production build, built-site Playwright tests, and the homepage asset report
- Root JavaScript contains no eager DocSearch, search-insights, or global syntax-language registration
- Homepage initial assets exclude Markdown, MarkdownComponents, and the full Highlight.js runtime
- Search implementation and styles load only after activation
- Responsive raster placements emit picture, srcset, and accurate sizes
- Every homepage image and video has numeric intrinsic dimensions
- Below-fold images do not become initial preload candidates
- Homepage CSS excludes documentation, DocSearch, and playground-only rules
- Direct loads and client transitions preserve styling and syntax highlighting without hydration errors
- Theme and preflight are emitted only once per page
- React Compiler is enabled incrementally without behavior or bundle regressions
- Each completed PR records before/after raw and gzip asset totals
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the DocsRoot React Router root route and the homepage, content, and playground route boundaries described here; then inspect the production/prerendered artifact and existing Vitest browser setup. Use the proposed standalone Playwright coverage and deterministic asset report to establish behavior and measurements. Done means the listed route payload, CSS, image, hydration, and build acceptance criteria pass without regressions.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- playwright, react, tailwindcss, vite
- Domain
- build-system, frontend, performance, testing
- Issue type
- Refactor
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100