CHECKOUT-9450: Lazy load payment strategies through essential build #2989
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/Why?
checkout-sdk-js
currently bundles all payment, shipping, and checkout button strategies for every payment provider, regardless of whether they are enabled by the merchant. This leads to unnecessary code in the main bundle, increasing its size and reducing performance.To address this problem, the following changes are introduced:
@bigcommerce/checkout-sdk/essential
, which excludes all payment, shipping, and checkout button strategies from the bundle.@bigcommerce/checkout-sdk/integrations/*
on the application side and passed intoCheckoutService
only when needed. This enables splitting strategies into separate chunks based on the component that loads them.CHECKOUT-9450.lazy_load_payment_strategies
experiment is active. We will compare the bundled strategies with those passed in from checkout-js and log any discrepancies in Sentry. Once we confirm that all passed-in strategies consistently match the existing ones, we will remove the bundled strategies.Rollout/Rollback
Disable
CHECKOUT-9450.lazy_load_payment_strategies
experimentTesting / Proof
The screenshots below show the improvements after the experiment is fully rolled out and the old code removed.
Before
716kb gzipped size for the initial scripts
After
546kb gzipped size for the initial scripts - ~24% improvement
This screenshot shows that payment methods still load as expected.