add queue to commercial for external initialisation#2402
Merged
dskamiotis merged 11 commits intomainfrom Feb 16, 2026
Merged
Conversation
|
Contributor
|
Size Change: +235 B (+0.1%) Total Size: 243 kB
ℹ️ View Unchanged
|
71985b1 to
af1278b
Compare
Contributor
0014f0f to
5698642
Compare
Jakeii
reviewed
Feb 10, 2026
on-ye
reviewed
Feb 10, 2026
on-ye
reviewed
Feb 11, 2026
docs/architecture/implementations/002-commercial-queue-implementation.md
Outdated
Show resolved
Hide resolved
4bfb19f to
7cb1f33
Compare
946e85a to
6343009
Compare
…ine types, and remove duplication
6343009 to
161da07
Compare
161da07 to
70bb55c
Compare
on-ye
approved these changes
Feb 16, 2026
Contributor
on-ye
left a comment
There was a problem hiding this comment.
Minor comment, but looks good
|
Seen on PROD (merged by @dskamiotis 2 minutes ago) Please check your changes! |
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.
What does this change?
Adds
window.guardian.commercial.queue- a global queue that external code can use to run functions after commercial initialisation.Implementation: Uses a factory function to create a queue object with explicit
push()andflush()methods. Chosen over a Proxy-based approach for better readability, easier debugging, and clearer intent.How it works (3 phases):
flush()executes buffered functions in orderWhy?
External code sometimes needs to run after commercial initializes (e.g., code that depends on ads being defined). Currently no clean way to do this without polling or timing hacks.
This pattern mirrors
googletag.cmdand provides a reliable "run when ready" mechanism.Alternative considered: Proxy-based queue that intercepts array methods. Rejected for complexity and reduced clarity.