This is tricky, see the comment. The core issue is that once a script is added to the page, there's not a generic way to check "is it loaded" (since the load event won't get fired if you add a listener too late) - each script could have its own way to check (which is what we do with window.Plaid below), but there doesn't seem to be a browser API to determine this.
Other solutions make different trade-offs (eg if it isn't loaded,
I also considered using patch-package (or copy-pasting) on the script hook to implement more logic to detect if the script was
This is tricky, see the comment. The core issue is that once a script is added to the page, there's not a generic way to check "is it loaded" (since the
load
event won't get fired if you add a listener too late) - each script could have its own way to check (which is what we do withwindow.Plaid
below), but there doesn't seem to be a browser API to determine this.Other solutions make different trade-offs (eg if it isn't loaded,
I also considered using
patch-package
(or copy-pasting) on the script hook to implement more logic to detect if the script was