fix: initialize interactions when configure runs after init (caching/defer plugins)#36
fix: initialize interactions when configure runs after init (caching/defer plugins)#36bfintal wants to merge 2 commits into
Conversation
|
Bugbot is not enabled for your account, so this pull request was not reviewed. Enable Bugbot in the Cursor dashboard to get automatic reviews on future PRs. |
|
Warning Review limit reached
Next review available in: 55 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthrough
ChangesInteractRunner lifecycle
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
🤖 Pull request artifacts
|
The editor's timeline runner calls configure() then init() on every preview refresh, so auto-initializing inside configure() would double init and duplicate listeners. Guard the auto-init with isFrontend so it only applies on the frontend, where the caching/defer ordering race actually occurs. Co-authored-by: Cursor <cursoragent@cursor.com>
|
Bugbot is not enabled for your account, so this pull request was not reviewed. Enable Bugbot in the Cursor dashboard to get automatic reviews on future PRs. |
Summary
Fixes gambitph/WP-Interactions#4 — interactions/animations sometimes don't start on the frontend when a caching/defer plugin (e.g. SiteGround Speed Optimizer with Minify JavaScript + Defer Render-blocking JavaScript) is active. The page loads but nothing animates until
InteractRunner.init()is run manually.Root cause
There's a race between
InteractRunner.configure()(builds the interactions, output as an inline script) andInteractRunner.init()(scheduled byfrontend.jsondomReady).configure()synchronously, thenDOMContentLoadedrunsinit(). Order is correct.InteractRunneryet and starts polling every 10ms. When the deferred bundle finally runsfrontend.js, the DOM is already parsed sodomReadyfires immediately and schedulesinit()at +1ms.init()wins the race and runs against an empty interactions list;configure()builds the interactions ~10ms later, but nothing callsinit()again → inert page.Fix
Make the runner order-independent in
src/frontend/scripts/class-runner.js:_isInitialized(set ininit(), cleared indestroy()).configure()runs afterinit()already ran, initialize the freshly-built interactions immediately.The normal path is unchanged (
configure()runs first,_isInitializedis false, no extra init).Test plan
InteractRunner.init().Made with Cursor
Summary by CodeRabbit