Skip to content

mehranmoghadasi/wordpress-performance-optimization

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 

Repository files navigation

🚀 WordPress Performance Optimization — Production Toolkit

Real-world optimization techniques used across 30+ client WordPress sites — achieving 45–50% average reduction in page load time.

WordPress PHP License: MIT


📋 Overview

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.

Results Achieved With This Toolkit

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

📁 Repository Structure

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

⚡ Core Optimization Areas

1. Server-Level Optimizations

  • Browser caching with long expiry headers
  • GZIP / Brotli compression for HTML, CSS, JS
  • FastCGI / OPcache configuration
  • CDN integration (Cloudflare)

2. WordPress-Level Optimizations

  • 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

3. Asset Optimizations

  • CSS and JS minification and concatenation
  • Image compression and WebP conversion
  • Critical CSS inlining
  • Font loading optimization (font-display: swap)

4. Core Web Vitals Targeting

  • LCP: Preload hero image, optimize server TTFB
  • FID / INP: Defer non-critical JavaScript
  • CLS: Set explicit width/height on all images and embeds

🚀 Quick Start

Step 1 — Add to your functions.php

// Copy content from php/functions-optimization.php into your theme's functions.php
require_once get_template_directory() . '/includes/performance.php';

Step 2 — Deploy Apache configuration

# Copy .htaccess to your WordPress root
cp apache/.htaccess /var/www/html/.htaccess

Step 3 — Run baseline audit

# Check your PageSpeed score before and after
# https://pagespeed.web.dev/

📊 Case Study — E-Commerce Client

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:

  1. Enabled GZIP compression via .htaccess
  2. Set browser cache expiry to 1 year for static assets
  3. Deferred WooCommerce cart scripts on non-cart pages
  4. Converted all images to WebP, added lazy loading
  5. Preloaded hero banner image
  6. 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

🛠️ Technologies & Tools

  • 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

👤 Author

Mehran Moghadasi — Full-Stack WordPress Developer & Digital Marketing Manager


📄 License

MIT License — Free to use, modify, and distribute with attribution.

About

WordPress speed optimization toolkit — PHP, .htaccess, and 50-point checklist

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages