Latest Results
ENG-9611: defer tracking/analytics scripts so they don't block render (#6568)
* ENG-9611: defer tracking/analytics scripts so they don't block render
External `src` trackers get `async_=True` (gtag loader, clearbit). Inline
trackers get `type="module"` so the browser defers them until after HTML
parsing (posthog, koala, common_room, rb2b, unify, default, gtag init).
Also switches all of these from `rx.script` to `rx.el.script`. The
trackers are placed via `App(head_components=...)` which is compiled
directly into `<Head>`, so the Helmet wrapper that `rx.script` adds is
redundant runtime cost.
`gtag_report_conversion` is intentionally left non-module — it defines
a global function called by name from `onclick` handlers.
* fix: assign gtag to window so type=module deferral doesn't break callers
A top-level `function gtag(){}` in a type=module script is module-scoped,
not installed on `window`. That breaks `gtag_report_conversion` and any
page code that calls `gtag('event', ...)` before the external gtag.js
loader finishes — `window.gtag` is undefined and the call throws.
Assign `window.gtag` explicitly. The `|| window.gtag` guard handles the
case where the async external loader executes before the deferred module
inline (so we don't clobber gtag.js's real implementation).
Caught by Greptile on PR #6568. Latest Branches
0%
carlos/add-cloud-deploy-overview 0%
carlos/remove-os-templates -5%
FarhanAliRaza:lighthouse-pr4-pr5 © 2026 CodSpeed Technology