6a. Preloading PayEngine Web-Component in SPA
To ensure fast performance and a seamless user experience, it's important to preload the PayEngine Web-Components as early as possible in your Single Page Application (SPA). This allows PayEngine to initialize the required scripts before the user interacts with any UI that depends on them.
How to Preload
Use the loadPayengine method during the early lifecycle of your app (e.g., in your root component or app bootstrap logic):
Understanding the lightweight Option
The lightweight option controls how much of the PayEngine Web-Components library is loaded:
lightweight:true - Only loads the core components required for accepting payments, including Secure Fields and other essential scripts. This mode is optimized for speed and ideal if you only need basic payment functionality.
Full mode (default) - If you do not specify lightweight, the full set of PayEngine Web-Components will be loaded. This includes everything needed for payments plus additional embedded web components like transaction history.
When to Use Each Mode
lightweight:true
You only need payment functionality (e.g., card entry, submit payment).
Full mode (default)
You also need access to embedded web components like transaction history etc.
Best Practices
Always preload the PayEngine Web-Components at the earliest possible point in your app lifecycle to reduce load time during user interaction.
Make sure to await the Promise returned by loadPayengine( ) if other parts of your app rely on the components being fully initialized.
For performance-sensitive flows, consider starting with lightweight: true and loading additional components dynamically only if/when needed.
Last updated