Reduce delay before API notice and trending landing search - #466
Merged
Merged
Conversation
Start Turnstile preload and session bootstrap in main.jsx before React hydration so trending ?s= links overlap challenge/network work with app startup. Pre-render the invisible widget, preload the Turnstile script in index.html, cache bootstrap timing for immediate notice display, and trigger landing search directly in the bootstrap callback instead of waiting for a follow-up effect. Co-authored-by: xenodus <xenodus@gmail.com>
Add GET /session?statusOnly=1 to return notice and maintenance without Turnstile or cookie minting. Fetch site status from main.jsx on load so the notice banner renders immediately, independent of session bootstrap. Co-authored-by: xenodus <xenodus@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Trending links (
/?s=...) and the API notice banner were delayed because Turnstile script load, session mint, and landing search all ran sequentially after React hydration.This PR overlaps that work with app startup and decouples the notice banner from Turnstile:
main.jsxcallspreloadTurnstile()andensureApiSession()beforecreateRoot().render(), so Turnstile +/sessionrun in parallel with React hydration.GET /session?statusOnly=1returns notice/maintenance without Turnstile or cookie minting.fetchSiteStatus()runs first inmain.jsxso the banner can render as soon as the lightweight probe returns.index.htmladds a<link rel="preload">for the Turnstile script.?s=search fires directly in the bootstrap.then()callback instead of waiting for a separatesessionBootstrappedeffect.Testing
make test— passgo test ./handler/... -run TestSession_StatusOnly— passhttp://localhost:5173/?s=Optauto-initiates search on loadPrivacy policy
No change — no new data collection.
UI
No visual changes; perceived latency improvement only. Notice banner now appears independently of Turnstile/session timing.