Performance: Shipping configuration
MEDIUM IMPACT
Shipping configuration affects page load speed and interaction responsiveness by adding backend logic and frontend scripts that calculate shipping costs dynamically.
<?php // Calculate shipping cost only on checkout with caching function get_shipping_cost() { $cost = get_transient('shipping_cost'); if (!$cost) { $cost = 25.00; // complex calculations and API calls set_transient('shipping_cost', $cost, 3600); } return $cost; } add_action('woocommerce_checkout_update_order_review', 'get_shipping_cost'); ?>
<?php
// Calculate shipping cost on every page load without caching
function calculate_shipping_cost() {
$cost = 25.00; // complex calculations and API calls
return $cost;
}
add_action('wp_head', 'calculate_shipping_cost');
?>| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Calculate shipping on every page load | Minimal | 0 | Low | [X] Bad |
| Calculate shipping only on checkout with caching | Minimal | 0 | Low | [OK] Good |