Performance: Payment gateway configuration
MEDIUM IMPACT
This affects page load speed and interaction responsiveness during checkout by how payment scripts and APIs are loaded and executed.
<?php // Enqueue payment gateway script asynchronously in footer function enqueue_payment_scripts_async() { wp_enqueue_script('payment-gateway', 'https://example.com/payment.js', array(), null, true); } add_action('wp_enqueue_scripts', 'enqueue_payment_scripts_async'); ?>
<?php // Enqueue payment gateway script synchronously in header function enqueue_payment_scripts() { wp_enqueue_script('payment-gateway', 'https://example.com/payment.js', array(), null, false); } add_action('wp_enqueue_scripts', 'enqueue_payment_scripts'); ?>
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Synchronous payment script in header | Minimal | Blocks rendering until script loads | High due to delayed paint | [X] Bad |
| Asynchronous payment script in footer | Minimal | Single reflow after script loads | Low, fast paint | [OK] Good |
| Multiple synchronous API calls on submit | None | Blocks main thread during calls | High interaction delay | [X] Bad |
| Batch or async API calls | None | Non-blocking main thread | Low interaction delay | [OK] Good |