Repository navigation
Conversation
A script injected after the page loaded runs with document.readyState already complete and then gets its own load event, so both boot triggers fired: implicit widgets were mounted twice (the first copy orphaned but still running) and the onload callback ran twice.
The script's load event fires straight after the script runs, so boot no longer waits for it. That removes the double trigger outright and lets widgets render when the script tag can't be found while the page is still loading. Implicit render marks each element it takes, so a second copy of the bundle on the same page only renders new elements, and it leaves the first copy's window.procaptcha in place so reset() and remove() still reach the existing widgets.
HughParry
marked this pull request as ready for review
October 26, 2026 17:07
…m/prosopo/captcha into fix/bundle-boot-once # Conflicts: # packages/procaptcha-bundle/src/index.ts
This branch has not been deployed
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 changed
loadevent (which fires immediately afterwards anyway).procaptchaelements that don't have a widget yet, and leaveswindow.procaptchapointing at the first copy.Why
onloadran twice.Effect
onloadcall per script, however the script is added.onloadcalled.reset()andremove()keep working after a second load.Tests
boot.unit.test.ts: after-load, still-loading, script-tag-not-found, implicit plusonload, and second-copy cases. 5 of the 10 fail on the previous code; all 93 bundle tests pass now.loadevent fires straight after it runs for normal, async, defer, module and injected scripts.