📃
Developer Docs
  • Overview
  • Integration Options
  • Webhooks
    • Build a webhook endpoint
    • Check signature
  • Getting Started
    • 1. Creating User Accounts
    • 2. User Account Types & Permissions
    • 3. Generate Access Tokens
    • 4. Choose Integration Options
    • 5. Securing Embedded UIs
      • 5a. Securing Embedded UIs Using HMAC (deprecated)
    • 6. Loading the frontend library
      • 6a. Preloading PayEngine Web-Component in SPA
    • 7. Custom styling the Web-Components
    • 8. Handling Callbacks from Web-Components
    • 9. Available Web-Components
    • 10. Available Webhooks
  • Merchant Onboarding
    • Overview
    • Integration Options
    • Onboarding/Payments Application Workflow
    • Embedded Onboarding UI
    • Merchant onboarding APIs
    • Partner's Onboarding UI
    • Merchant Lifecycle
    • Onboarding to Partner Relationships
  • Processing Payments
    • Introduction
      • Transaction Flow and Status
    • SecureFields JS
      • SecureFields Bank Account
      • Using tokens
    • Credit Card Form
    • Connect with Plaid
    • Connect Mailgun
    • 3D Secure
    • Payments API
    • Searching Transactions
    • Registering a cloud connected device
    • Apple Pay
      • Apple Pay in your native app
    • Google Payâ„¢
    • Level 2 and Level 3 Data
    • Fraud Prevention
    • Reporting
    • PCI Compliance
    • Address Verification Service (AVS) Check
    • Hosted Payments
    • Tap to Pay
  • Card Account Updater
  • ORCHESTRATION SYSTEM
    • Orchestration Overview
    • Onboarding Orchestration
    • Transactions Orchestration
    • Omnicommerce Orchestration
    • Merchant Servicing
    • Universal Reporting
  • TOKENIZATION
    • Automatic Network Tokenization
    • Token Migration Process
  • DISPUTE MANAGEMENT
    • Retrieval Requests & Chargebacks
  • Certification
    • Partner Certification
  • Data Sharing
    • Secure Data Sharing with PayEngine
  • eCommerce Integration
    • PayEngine Payment Gateway for WooCommerce
Powered by GitBook
On this page
  • How to Preload
  • Understanding the lightweight Option
  • When to Use Each Mode
  • Best Practices
  1. Getting Started
  2. 6. Loading the frontend library

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):

loadPayengine({
    publicKey: config.PAYENGINE_PUBLIC_KEY,
    //lightweight: true // Optional
}).then((pe) => {
    console.log('PayEngine initialized', pe);
});

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

Mode
Use When...

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.

Previous6. Loading the frontend libraryNext7. Custom styling the Web-Components

Last updated 28 days ago