Load the tracker script async instead of deferred - #331
Conversation
Deferred scripts run before DOMContentLoaded, so while the browser waits for a tracker script that can't be reached (e.g. a proxied script on a server that has gone offline), DOMContentLoaded doesn't fire and everything waiting for it stalls: menus, sliders, preloader overlays. Load it async, like Plausible's own snippet. The tracker handles loading before or after the inline plausible.init(): options set before it loads are picked up from plausible.o, and afterwards plausible.init is the tracker's own. Events sent before it has loaded are queued, as before.
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (3)
Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review. 📝 WalkthroughWalkthroughThe compatibility filter now adds ChangesTracker script loading
Priority: ➖ Normal Change: Bug fix · Severity of issue fixed: Medium Merge Risk: ⚪ Minimal · up to The tracker now loads asynchronously, and the supported initialization pattern preserves queued calls if it loads first. No merge-blocking issue is established; the change is ready for normal checks. Security Architecture ReviewSecurity architecture risk: 🔵 Low · up to The change reduces the impact of an unreachable tracker without visibly expanding permissions or access. The remaining uncertainty is whether the external tracker applies privacy-sensitive configuration correctly in both possible initialization orders. Retained concerns Security review detailsSecurity Blast Radius
Security Findings and Attack Paths
Trust Boundaries and Controls
Resilience and Maintainability Implications
Hardening Proposals
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 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 |
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
|
@coderabbitai review |
✅ Action performedReview finished.
|
Follow-up to #330: make sure a tracker script that can't be reached can never hold up a page again, whatever the cause.
Why
The tracker script is loaded with
defer. That doesn't block rendering, but deferred scripts run beforeDOMContentLoaded. While the browser waits for a script that doesn't respond (like the proxied script on an offline server in #330),DOMContentLoadeddoesn't fire, and everything waiting for it stalls with it: menus, sliders, preloader overlays, etc.Change
asyncinstead, like Plausible's own snippet.data-cfasync='false'and the other optimization-plugin exclusions stay as they are.plausible.init(...)that follows it:plausible.o, and the tracker picks them up when it loads (plausible.o&&S(plausible.o));plausible.init, which the inline script then calls.DOMContentLoaded) are queued, as before.Testing
Live, as a logged-out visitor:
DOMContentLoadedasync, loadedasync, loaded404event (202, 202)async, not loadeddeferondevelop: not fired after 30 s)Note: #328 and #330 also add a 2.6.3 changelog section, so whichever is merged later needs a trivial readme merge.
Summary by CodeRabbit