You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Perf follow-up D — speculative variant-chunk preload (parallelise the cold path)
From the first-render deep-dive. Measured cold waterfall (no cache, real flag round-trip):
34→128ms welcome.js
510→1043ms PostHog config/flags round-trip (ph.wcpos.com)
1014→1056ms free-plus.js + .css ← chunk does not START until the flag resolves
→ first paint ~1.3s
The variant chunk request is serially gated behind the PostHog flag resolution. On a first-ever visit we genuinely must wait for the flag to know the assigned variant (rendering fallback-first would make every first visit a fallback render, which §6.1 excludes from cohorts) — but we can still warm the network in parallel.
Proposal
While resolveFlag() is pending in prepareVariant, kick off a preload of the fallback (free-plus) chunk's JS + CSS (<link rel="preload" as="script/style"> or a fetch()), so that whichever variant is chosen, the most-likely chunk is already in the HTTP cache and injectAssets is near-instant. Options:
Preload only the fallback (free-plus) — cheapest, covers the common case (and the current flag-disabled state where everyone is fallback).
Preload both variant chunks (~150KB) — covers either assignment, at the cost of one extra unused download.
Caveats / acceptance
Preload (not execute) — the chunk must still be injected via the existing injectAssets so it runs exactly once after the runtime is exposed. No double-execution.
No effect on exposure/SRM accounting (preload is network-only).
Measure cold time_to_render_ms p90 before/after; ensure no regression to the fallback-rate or landing_error guardrails.
Perf follow-up D — speculative variant-chunk preload (parallelise the cold path)
From the first-render deep-dive. Measured cold waterfall (no cache, real flag round-trip):
The variant chunk request is serially gated behind the PostHog flag resolution. On a first-ever visit we genuinely must wait for the flag to know the assigned variant (rendering fallback-first would make every first visit a fallback render, which §6.1 excludes from cohorts) — but we can still warm the network in parallel.
Proposal
While
resolveFlag()is pending inprepareVariant, kick off a preload of the fallback (free-plus) chunk's JS + CSS (<link rel="preload" as="script/style">or afetch()), so that whichever variant is chosen, the most-likely chunk is already in the HTTP cache andinjectAssetsis near-instant. Options:Caveats / acceptance
injectAssetsso it runs exactly once after the runtime is exposed. No double-execution.time_to_render_msp90 before/after; ensure no regression to the fallback-rate orlanding_errorguardrails.Came out of #27 (instant cached render + skeleton + PostHog trim).