Real-world optimization techniques used across 30+ client WordPress sites — achieving 45–50% average reduction in page load time.
This repository contains the complete WordPress performance optimization toolkit I've developed and refined across 30+ client projects over 13 years. Every technique here has been tested in real production environments and validated using Google PageSpeed Insights and Core Web Vitals measurements.
| Metric | Before | After | Improvement |
|---|---|---|---|
| Page Load Time (avg) | 6.2s | 2.8s | 55% faster |
| Google PageSpeed Score (Mobile) | 38–52 | 78–91 | +39–46 pts |
| Largest Contentful Paint (LCP) | 5.8s | 2.1s | 64% faster |
| Cumulative Layout Shift (CLS) | 0.38 | 0.04 | 89% reduction |
| Time to First Byte (TTFB) | 820ms | 210ms | 74% faster |
wordpress-performance-optimization/
├── php/
│ └── functions-optimization.php # WordPress functions.php optimizations
├── apache/
│ └── .htaccess # Apache caching, compression, security
├── nginx/
│ └── nginx-cache.conf # Nginx FastCGI caching configuration
├── js/
│ └── lazy-load.js # Vanilla JS lazy loading for images
├── checklist/
│ └── performance-checklist.md # 50-point pre-launch performance checklist
└── README.md
- Browser caching with long expiry headers
- GZIP / Brotli compression for HTML, CSS, JS
- FastCGI / OPcache configuration
- CDN integration (Cloudflare)
- Disable unused WordPress features (emojis, embeds, XML-RPC)
- Optimized database queries and transient cleanup
- Dequeue non-critical scripts and styles
- Lazy load images natively and via JS fallback
- CSS and JS minification and concatenation
- Image compression and WebP conversion
- Critical CSS inlining
- Font loading optimization (
font-display: swap)
- LCP: Preload hero image, optimize server TTFB
- FID / INP: Defer non-critical JavaScript
- CLS: Set explicit width/height on all images and embeds
// Copy content from php/functions-optimization.php into your theme's functions.php
require_once get_template_directory() . '/includes/performance.php';# Copy .htaccess to your WordPress root
cp apache/.htaccess /var/www/html/.htaccess# Check your PageSpeed score before and after
# https://pagespeed.web.dev/Client: Online retail store (WooCommerce, 800+ products) Problem: 7.2s load time causing 68% mobile bounce rate Tools Used: This toolkit + Cloudflare CDN + WP Rocket plugin config
Actions Taken:
- Enabled GZIP compression via
.htaccess - Set browser cache expiry to 1 year for static assets
- Deferred WooCommerce cart scripts on non-cart pages
- Converted all images to WebP, added lazy loading
- Preloaded hero banner image
- Enabled Cloudflare's Rocket Loader and Auto-Minify
Results:
- Load time: 7.2s → 2.9s (60% improvement)
- Mobile PageSpeed: 34 → 84
- Bounce rate: 68% → 41% (27-point reduction)
- Conversion rate: +22% within 30 days
- WordPress — CMS platform
- PHP 7.4 / 8.1 — Server-side optimization
- Apache / Nginx — Web server configuration
- Cloudflare — CDN and edge caching
- Google PageSpeed Insights — Performance measurement
- GTmetrix / WebPageTest — Detailed waterfall analysis
- Chrome DevTools — Core Web Vitals debugging
Mehran Moghadasi — Full-Stack WordPress Developer & Digital Marketing Manager
- 📍 Edmonton, Alberta, Canada
- 📧 mehran.moghadasi@gmail.com
MIT License — Free to use, modify, and distribute with attribution.