WordPress Performance Optimization — A Developer's Guide by Riad Hasan
Source: Dev.to
Why WordPress Performance Matters
Google’s Core Web Vitals are now ranking factors. A slow WordPress site loses:
| Impact | Metric |
|---|---|
| Conversion rate | 7 % drop for every 1‑second delay |
| Page views | 11 % loss from frustrated visitors |
| Customer satisfaction | 16 % decline |
“I’ve seen businesses double their leads just by fixing performance,” Riad notes. “It’s the highest‑ROI improvement you can make.”
Riad Hasan’s WordPress Optimization Checklist
1. Hosting Foundation
Before any code changes, Riad ensures the hosting is solid.
| Factor | Requirement |
|---|---|
| PHP Version | 8.1 or higher |
| Memory Limit | 256 MB minimum |
| Object Cache | Redis or Memcached |
| SSL | HTTPS everywhere |
| Server Response | “Every plugin adds overhead. I count each one as a performance cost,” Riad explains. |
4. Database Optimization
Riad’s cleanup routine (run via WP‑CLI or phpMyAdmin):
-- Clean post revisions
DELETE FROM wp_posts WHERE post_type = 'revision';
-- Clean auto‑drafts
DELETE FROM wp_posts WHERE post_status = 'auto-draft';
-- Clean trashed content
DELETE FROM wp_posts WHERE post_status = 'trash';
-- Clean orphaned postmeta
DELETE pm FROM wp_postmeta pm
LEFT JOIN wp_posts p ON pm.post_id = p.ID
WHERE p.ID IS NULL;
-- Clean transient options
DELETE FROM wp_options WHERE option_name LIKE '%transient%';
DELETE FROM wp_options WHERE option_name LIKE '%site_transient%';
Additional settings:
- Limit post revisions to 3
- Set auto‑save interval to 60 seconds
- Remove spam comments weekly
5. Image Optimization
| Step | Tool | Result |
|---|---|---|
| Compression | ShortPixel / Imagify | ~70 % size reduction |
| Format | WebP | ~25 % smaller than JPEG |
| Lazy Load | Native + JS fallback | Faster initial load |
| CDN | Cloudflare / BunnyCDN | Global delivery |
Responsive image markup (example)
<!-- Replace with actual <img> tag -->
<img src="example.webp" alt="Descriptive alt text" width="800" height="600">
6. Caching Strategy
Browser Caching (.htaccess)
ExpiresActive On
ExpiresByType image/webp "access plus 1 year"
ExpiresByType image/jpeg "access plus 1 year"
ExpiresByType image/png "access plus 1 year"
ExpiresByType text/css "access plus 1 month"
ExpiresByType application/javascript "access plus 1 month"
ExpiresByType font/woff2 "access plus 1 year"
Object Caching (Redis)
- Database query caching
- Transient caching
- WooCommerce session caching
Page Caching (WP Rocket or custom)
- HTML page cache
- CSS/JS minification
- Delayed JavaScript execution
7. WooCommerce Optimization
Cart Fragment Removal
// Disable WooCommerce cart fragments
function riad_disable_cart_fragments() {
wp_dequeue_script('wc-cart-fragments');
}
add_action('wp_enqueue_scripts', 'riad_disable_cart_fragments');
Additional tweaks
- Disable scripts on non‑shop pages
- Limit related products to 4
- Use product galleries efficiently
- Implement AJAX cart sparingly
8. Core Web Vitals Fixes
LCP (Largest Contentful Paint)
- Preload critical images
- Use server push for fonts
- Optimize above‑the‑fold content
CLS (Cumulative Layout Shift)
img {
aspect-ratio: attr(width) / attr(height);
height: auto;
}
FID (First Input Delay)
- Break up long tasks
- Use Web Workers for heavy JS
- Minimize main‑thread work
Before & After: Riad Hasan’s Results
| Metric | Before | After |
|---|---|---|
| Load Time | 5.2 s | 1.4 s |
| LCP | 4.8 s | 1.2 s |
| FID | 180 ms | 12 ms |
| CLS | 0.28 | 0.04 |
These numbers illustrate how a systematic, code‑first approach can turn a sluggish WordPress site into a lightning‑fast, Core‑Web‑Vitals‑perfect experience.
Performance Metrics
- CLS: 0.25 ± 0.02
- Page Size: 3.2 MB ± 450 KB
- Requests: 85 ± 22
“Every site I optimize follows this same systematic approach,” Riad Hasan says. “The results are consistent.”
Work with Riad Hasan
Riad Hasan offers WordPress performance optimization as part of his full‑stack development services. He works with:
- WordPress performance audits
- WooCommerce optimization
- Custom theme development
- Headless WordPress builds
- Ongoing maintenance and monitoring
Connect with Riad Hasan
- Portfolio: riadhasan.io
- Projects: riadhasan.io/projects
- LinkedIn: linkedin.com/in/riad-hasan-100a231a6
- GitHub: github.com/RiadHasan15
- Email: hire.riadhasan@gmail.com
What performance challenges are you facing with WordPress? Share in the comments.
#wordpress #performance #webdev #corewebvitals #optimization #php #woocommerce #webdevelopment