Page MenuHomePhabricator

Make sure gateway script fully loaded first for Dlocal, Adyen Checkout and Google
Closed, ResolvedPublic

Description

We assuming the dlocal/adyen/google script is fully loaded before we their Instance:

Suggested if we should replace the script we're adding in DlocalGateway with a preload link (https://www.keycdn.com/blog/resource-hints) and ensure all this logic gets loaded after it is run by putting it in a callback to mw.loader.load() https://doc.wikimedia.org/mediawiki-core/master/js/#!/api/mw.loader.

We don't seem to be ensuring that external scripts are loaded before using them. We are just assuming that functions which run on pageready will have access to things defined in external scripts added as script tags in the <head>.

Let's maybe use mw.loader.load() to make sure things are loaded before we run dependent scripts. We could probably keep adding the script tag in the head (or maybe a link rel=prefetch? ) so we don't slow anything down.

Event Timeline

Change 881013 had a related patch set uploaded (by Wfan; author: Wfan):

[mediawiki/extensions/DonationInterface@master] WIP: Preload third party script

https://gerrit.wikimedia.org/r/881013

Change 881050 had a related patch set uploaded (by Ejegg; author: Ejegg):

[mediawiki/extensions/DonationInterface@master] Adyen: ensure external script loads first

https://gerrit.wikimedia.org/r/881050

Change 881050 merged by jenkins-bot:

[mediawiki/extensions/DonationInterface@master] Adyen: ensure external script loads first

https://gerrit.wikimedia.org/r/881050

AnnWF renamed this task from Make sure gateway script fully loaded first for Dlocal, Adyen Checkout and Amazon to Make sure gateway script fully loaded first for Dlocal, Adyen Checkout and Google .Jan 19 2023, 7:35 PM
AnnWF updated the task description. (Show Details)

Oh I see, Amazon doesn't need it because we just define a callback and wait for them to call it when they're ready!

window.onAmazonPaymentsReady = ...

Change 881013 merged by jenkins-bot:

[mediawiki/extensions/DonationInterface@master] Preload third party script for google and dlocal

https://gerrit.wikimedia.org/r/881013