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
Split Prebid into deferred bundle to reduce render-blocking JS (#393)
* Split Prebid into deferred bundle to reduce render-blocking JS by 88%
Prebid.js (168 KB) was 80% of the TSJS unified bundle, blocking page
rendering. Split it into a separate `<script defer>` tag so the
critical-path bundle drops from 190 KB to 22 KB.
Changes across 8 files:
- crates/js/src/bundle.rs: add `single_module_hash()` and
`all_module_ids_excluding()` for deferred module serving
- crates/js/src/lib.rs: export new bundle functions
- crates/common/src/tsjs.rs: add `DEFERRED_MODULE_IDS` constant (single
source of truth), deferred script tag generation functions, update
`_all()` variants to exclude deferred modules
- crates/common/src/integrations/registry.rs: add
`js_module_ids_immediate()` and `js_module_ids_deferred()` with tests
- crates/common/src/html_processor.rs: inject split tags at `<head>`:
synchronous main bundle + deferred prebid tag
- crates/common/src/publisher.rs: serve deferred modules at
`/static/tsjs=tsjs-{id}.min.js` with allowlist validation and tests
- crates/common/src/integrations/prebid.rs: fix test assertion for new
deferred tag presence
- docs/guide/integration-guide.md: update Prebid load timing docs
Closes#358
* Document deferred vs immediate loading for each integration
Update CLAUDE.md and integration-guide.md to indicate which
integrations use deferred loading and explain the two loading modes.
* Replace hardcoded DEFERRED_MODULE_IDS with per-integration builder flag
Each integration now declares deferred JS loading via .with_deferred_js()
on IntegrationRegistrationBuilder, replacing the static constant that
required manual maintenance. Removes unused _all() convenience functions
from tsjs.rs and all_module_ids_excluding() from bundle.rs.
* Fixed formatting of settings.json
* Fixed formatting
* Fix cache-busting hash to reflect full unified bundle content
tsjs_script_src(&["testlight"]) hashed only core+testlight, but the
unified bundle contains all immediate modules. Added tsjs_unified_script_src()
and tsjs_unified_script_tag() that hash all module IDs so the cache key
matches the actual served content.
* Bootstrap pbjs globals before deferred Prebid bundle loads
Inject window.pbjs, pbjs.que, and pbjs.cmd in the head injector inline
script so publisher pages with bare pbjs.que.push() calls don't throw
before the deferred bundle executes. Also fix stale doc references that
still described Prebid as part of the unified sync bundle.
* Added #[must_use]
-`creative` is JS-only (no Rust registration); `nextjs`, `aps`, `adserver_mock` are Rust-only.
242
-
-`IntegrationRegistry::js_module_ids()` maps registered integrations to JS module names.
242
+
- Integrations opt into deferred loading via `.with_deferred_js()` on the registration builder. Deferred modules are served as separate `<script defer>` tags instead of being concatenated into the main bundle.
243
+
-`IntegrationRegistry::js_module_ids_immediate()` returns modules for the main bundle; `js_module_ids_deferred()` returns modules loaded with `defer`.
0 commit comments