Skip to content

Conversation

@hartmannr76
Copy link
Contributor

FYI @fikus @ChrisAntaki @jpettitt

This is meant more of a demo for what lazily loading the pay.js script would look like.

Essentially:

  1. Load the script asynchronously as part of our script loading
  2. We need to have hooks in place to let us know when it is ready, hence the use of the Promise

Results:
Before: dist/basic-subscriptions.js 199.02 kB │ gzip: 59.10 kB
After: dist/basic-subscriptions.js 163.02 kB │ gzip: 48.90 kB

Thats an 18% decrease in raw bundle size and a 17.26% decrease in zipped size. Thats fairly significant, plus it removes tech debt from our end on needing to maintain a copy of it

Complications:
If we want to just directly use it the way we currently do, the web-activities code in pay.js needs to expose its public methods since they are getting renamed at the moment
image

@ChrisAntaki
Copy link
Collaborator

Nice!

// so it can be passed to gpay_async.js and stored in payment clearcut log.
PaymentsAsyncClient.googleTransactionId_ = googleTransactionId;
return new PaymentsAsyncClient(
google.payments.api.PaymentsAsyncClient.googleTransactionId_ =
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We might need to quote the googleTransactionId_ property name, so Terser doesn't mangle it in the new Vite build system

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants