MOHIMDEV
WordPress • Mobile Apps • Full-Stack
0%
Opening scrapbook... 📖
Back to developer notes
WordPress
Oct 18, 2026•6 min read•Verified Best Practice

How to Optimize WordPress & WooCommerce Stores for Sub-Second Loading Speed

A comprehensive guide on database indexing, server caching, image AVIF compression, and reducing WooCommerce asset bloat to achieve a 95+ Google PageSpeed score.

MD. MOHIM MOLLA
MD. MOHIM MOLLA
WordPress & Mobile Full-Stack Specialist
#WordPress#WooCommerce#Redis Cache
Executive Summary & Core Thesis

“A comprehensive guide on database indexing, server caching, image AVIF compression, and reducing WooCommerce asset bloat to achieve a 95+ Google PageSpeed score.”

In modern e-commerce, every 100 milliseconds of loading latency can reduce conversion rates by up to 7%. Standard WooCommerce installs often load dozens of unneeded scripts, tracking pixels, and cart fragments across every single page—even simple blog posts and the homepage.

To achieve blazing speed, we implement selective script dequeueing, Redis object caching, Cloudflare full-page caching, and WebP/AVIF automated conversion. By intercepting WordPress's wp_enqueue_scripts hook, we guarantee that heavy checkout scripts only load when the customer is actively browsing the shop or completing a transaction.

Database optimization is equally critical: cleaning up expired transients, optimizing the wp_options table, and indexing WooCommerce order tables drastically reduces TTFB (Time to First Byte). When paired with server-level Nginx microcaching, pages render virtually instantaneously for global visitors.

Finally, asset bundling with modern HTTP/3 and Brotli compression ensures that critical CSS is inlined directly in the initial HTML payload, eliminating render-blocking bottlenecks and guaranteeing an effortless 95+ score on Google Lighthouse.

Key Architectural Takeaways

  • Selective script dequeueing prevents WooCommerce cart fragments from bogging down static landing pages.
  • Redis persistent object caching reduces dynamic database query executions by over 80%.
  • Converting media to WebP/AVIF format with native responsive srcset tags reduces total payload size by up to 65%.
  • Scheduled cleaning of expired transients and indexing custom postmeta keys prevents wp_options table bloat.

Benchmark Impact (Before vs. After Optimization)

Metric TestedBaseline (Before)Optimized (After)
Mobile PageSpeed Score42 / 10098 / 100
Time to First Byte (TTFB)1,240 ms180 ms
Largest Contentful Paint (LCP)3.8 s0.9 s
Total Page Payload4.6 MB1.1 MB

Production Implementation Snippet

functions.php — Script Dequeueing & Redis Cachephp
// Disable WooCommerce cart fragments on non-eCommerce pages
add_action('wp_enqueue_scripts', function() {
    if (!is_woocommerce() && !is_cart() && !is_checkout()) {
        wp_dequeue_script('wc-cart-fragments');
        wp_dequeue_style('woocommerce-general');
    }
}, 99);

// Enable Redis Object Cache Compression
define('WP_REDIS_COMPRESSION', 'zstd');
define('WP_REDIS_DATABASE', 0);
KNOWLEDGE BASE

More Technical Notes & Guides

🕷️Spidey: