Title: Published pages ship the layer tree twice, making large pages 0.7–0.9 MB · Issue #685 · ycode/ycode · GitHub
Open Graph Title: Published pages ship the layer tree twice, making large pages 0.7–0.9 MB · Issue #685 · ycode/ycode
X Title: Published pages ship the layer tree twice, making large pages 0.7–0.9 MB · Issue #685 · ycode/ycode
Description: Summary Every published page is shipped twice: once as HTML and once as the RSC Flight payload that LayerRendererPublic (a 'use client' component) needs to render the same page again. The layer tree JSON in that payload is larger than th...
Open Graph Description: Summary Every published page is shipped twice: once as HTML and once as the RSC Flight payload that LayerRendererPublic (a 'use client' component) needs to render the same page again. The layer tre...
X Description: Summary Every published page is shipped twice: once as HTML and once as the RSC Flight payload that LayerRendererPublic (a 'use client' component) needs to render the same page again. The l...
Opengraph URL: https://github.com/ycode/ycode/issues/685
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Published pages ship the layer tree twice, making large pages 0.7–0.9 MB","articleBody":"## Summary\n\nEvery published page is shipped twice: once as HTML and once as the RSC Flight payload that `LayerRendererPublic` (a `'use client'` component) needs to render the same page again. The layer tree JSON in that payload is larger than the markup it produces, so a large homepage is 0.7–0.9 MB of uncompressed HTML, of which about two thirds is Flight data.\n\nFollows #447, which removed unused component definitions from the payload.\n\n## Measurements\n\nA large published homepage (about 900 layers):\n\n| Part | Uncompressed |\n|---|---|\n| Whole HTML document | 915 KB |\n| Visible markup | 279 KB |\n| Flight payload (`self.__next_f`) | 619 KB |\n| – `layers` prop of `LayerRendererPublic` | 417 KB |\n| – `layers` prop of `AnimationInitializer` | 56 KB |\n| – other props (`pages`, `serverSettings`, `resolvedAssets`, …), custom code, head | ~140 KB |\n\nThree other sites show the same pattern: Flight is 64–70% of the document. Over the wire the impact is smaller (this page is 96 KB with Brotli, 138 KB with gzip), because Brotli catches part of the duplication. Clients that don't send `Accept-Encoding` (uptime monitors, some crawlers) get the full 915 KB on every request.\n\nInside the main `layers` prop the largest fields are `variables` (129 KB: icon SVG strings, Tiptap text docs, links), `classes` (98 KB), `_masterComponentId` (39 KB), `id` (36 KB), `interactions` (22 KB), `settings` (21 KB) and `componentOverrides` (19 KB).\n\n## Proposal\n\n### 1. Quick trims (low risk, `PageRenderer.tsx` only)\n\nAbout 110 KB (12%) on the page above, 5–10% on the others.\n\n- **Drop `_masterComponentId` in `stripSSROnlyData`.** The client only reads it for translation lookups, and published pages already bake translations into the layers and pass only page/folder slug rows (`clientLinkTranslations`).\n- **Drop `componentOverrides` in `stripSSROnlyData`.** Overrides are applied on the server, and `LayerRendererPublic` never reads them.\n- **Make `extractAnimationLayers` return a flat list.** `AnimationInitializer` only collects layers with `interactions` or `settings.hidden`; it never uses the tree structure (collection extras arrive via `ITEMS_INJECTED_EVENT`). On the page above that is 9 of 485 layers. Returning just those, without the skeleton, takes the prop from 56 KB to about 25 KB.\n- **Drop `interactions` from the main tree.** `LayerRendererPublic` only reads them for rich-text-embedded components (`layerTreeHasInteractions` on `_resolvedLayers`, which live in variables and are unaffected). Today the animation prop references the main tree's `interactions` objects (`$\u003crow>:…` refs), so they would move into the animation prop rather than disappear, which is fine once that prop is flat.\n- **Open question:** 572 of 902 layers carry a top-level `hidden: true` while rendering normally, and the public renderer never reads `layer.hidden` (only `settings.hidden`). It looks like a leftover builder flag. Confirm before stripping it (8 KB).\n\n### 2. Render static layers as Server Components (medium, about 30–40% of Flight)\n\nSplit `LayerRendererPublic` so static layers (text, images, icons, plain divs, links) render on the server and only interactive subtrees (forms, sliders, lightbox, filters, load more, locale selector, password form, maps) are client components with their own slim props. Static content would then be serialized as rendered elements instead of layer JSON plus the props needed to resolve it (`pages`, `folders`, `resolvedAssets`, `serverSettings`, `collectionItemSlugs`).\n\nThe App Router still embeds server-rendered output in Flight, so the page body is still duplicated, but at roughly markup size instead of 1.5× markup.\n\n### 3. Published pages without Flight (large, about 65% of the document)\n\nServe published pages as plain HTML with no RSC payload, and hydrate only the interactive islands, for example with small `hydrateRoot` entry points keyed by `data-layer-id`. That removes the duplication entirely (915 KB → ~300 KB on the page above). It needs a separate rendering path for published pages and touches caching/ISR, interactions, forms, filters and error pages, so it should be scoped on its own.\n\n## Suggested order\n\n1 now, 2 as a follow-up, 3 only if 2 is not enough.\n\n## How to measure\n\n```bash\ncurl -s https://\u003csite>/ -o page.html\n# total size, Flight size\nwc -c page.html\ngrep -o '\u003cscript>self.__next_f.push(.*\\?)\u003c/script>' page.html | wc -c\n```\n","author":{"url":"https://github.com/ysamcode","@type":"Person","name":"ysamcode"},"datePublished":"2026-11-17T08:45:07Z","url":"https://github.com/ycode/ycode/issues/685"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:09aa782f-838f-efa1-e549-017cb214f45c |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 82AE:1C7627:34415:4731B:6AFE30A2 |
| html-safe-nonce | 425e66fef1415f89fb53754481e390f44da922f1a77bdc62ef2fb1da1bc2448e |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4MkFFOjFDNzYyNzozNDQxNTo0NzMxQjo2QUZFMzBBMiIsInZpc2l0b3JfaWQiOiIzMzg4ODI3OTYxMTEyMDE1MDEwIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 674ebd27fc14538ec21e15ea49312bd936d7d18afc8ba597ec910371b74c7360 |
| hovercard-subject-tag | issue:6440780286 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/ycode/ycode/685/issue_layout |
| twitter:image | https://opengraph.githubassets.com/2e32fa4da712bca1bc1d2ed8f1f3bba3025ab77bbd3837978a7872700568ddca/ycode/ycode/issues/685 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/2e32fa4da712bca1bc1d2ed8f1f3bba3025ab77bbd3837978a7872700568ddca/ycode/ycode/issues/685 |
| og:image:alt | Summary Every published page is shipped twice: once as HTML and once as the RSC Flight payload that LayerRendererPublic (a 'use client' component) needs to render the same page again. The layer tre... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | ysamcode |
| hostname | github.com |
| expected-hostname | github.com |
| None | d70e31220a67f6376c108d2416fa8e7df854c1065b1672ab7a88ab6dc3a809e2 |
| turbo-cache-control | no-preview |
| go-import | github.com/ycode/ycode git https://github.com/ycode/ycode.git |
| octolytics-dimension-user_id | 65892203 |
| octolytics-dimension-user_login | ycode |
| octolytics-dimension-repository_id | 1165452593 |
| octolytics-dimension-repository_nwo | ycode/ycode |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 1165452593 |
| octolytics-dimension-repository_network_root_nwo | ycode/ycode |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | ccb88d9c92abe69245b429398c8a57ae87070c7c |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width