♻️ use global URL constructor and fall back to pristine iframe only when needed - #4967
Open
BenoitZugmeyer wants to merge 2 commits into
Open
♻️ use global URL constructor and fall back to pristine iframe only when needed#4967BenoitZugmeyer wants to merge 2 commits into
BenoitZugmeyer wants to merge 2 commits into
Conversation
🎉 All green!🧪 All tests passed 🎯 Code Coverage (details) 🔗 Commit SHA: cb4049b | Docs | View more details | Give us feedback! |
Bundles Sizes Evolution
|
BenoitZugmeyer
force-pushed
the
benoit/url-polyfill-fallback
branch
2 times, most recently
from
August 20, 2026 16:12
43504fc to
86cdaa1
Compare
BenoitZugmeyer
marked this pull request as ready for review
August 20, 2026 16:18
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 86cdaa17ca
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
BenoitZugmeyer
force-pushed
the
benoit/url-polyfill-fallback
branch
2 times, most recently
from
August 20, 2026 16:36
f1637bd to
0c09ad8
Compare
amortemousque
approved these changes
Aug 21, 2026
mormubis
approved these changes
Aug 21, 2026
…hen needed Creating a hidden iframe on every page just to read an unpatched URL constructor is wasteful when the global one works fine. Probe it with a relative-URL resolution check and only fall back to the iframe-sourced constructor when it is patched or broken. This also drops the contentWindow shim in the Shopify sandbox patch, no longer needed now that the iframe path is not taken by default.
BenoitZugmeyer
force-pushed
the
benoit/url-polyfill-fallback
branch
from
August 21, 2026 12:12
0c09ad8 to
cb4049b
Compare
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.
Motivation
The SDK creates a hidden
<iframe>on every page just to read an unpatchedURLconstructor, even though the globalURLworks correctly in the vast majority of environments. This is wasteful and can interfere with strict sandboxed contexts (e.g. Shopify Custom Pixels). We should only fall back to the iframe when the global constructor is actually patched or broken.Changes
buildUrlnow probes the globalURLconstructor with a relative-URL resolution check and uses it directly when it behaves correctly, falling back to the pristine iframe-sourced constructor only when needed.HTMLIFrameElement.prototype.contentWindowshim from the Shopify sandbox patch, no longer necessary now that the iframe path is not taken by default.urlPolyfill.spec.tsnext to its source file injs-core.Test instructions
window.URLwith a throwing function in the console, then trigger a navigation: URLs should still resolve via the iframe fallback.Checklist