Quick reference guide for speeding up WordPress sites
1. Hosting & Server
Choose Quality Hosting
- Avoid shared hosting for high-traffic sites
- Managed WordPress hosting recommended (WP Engine, Kinsta, Flywheel)
- VPS/Cloud for flexibility (DigitalOcean, Linode, Vultr)
- Ensure PHP 8.1+ (latest stable version)
Server Configuration
# .htaccess - Enable Gzip Compression
<IfModule mod_deflate.c>
AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css text/javascript application/javascript application/json
</IfModule>
# Browser Caching
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/jpg "access plus 1 year"
ExpiresByType image/jpeg "access plus 1 year"
ExpiresByType image/gif "access plus 1 year"
ExpiresByType image/png "access plus 1 year"
ExpiresByType image/webp "access plus 1 year"
ExpiresByType text/css "access plus 1 month"
ExpiresByType application/javascript "access plus 1 month"
ExpiresByType application/pdf "access plus 1 month"
</IfModule>
2. Caching Strategy
Page Caching (Choose One)
- WP Rocket (Premium, easiest)
- W3 Total Cache (Free, powerful)
- WP Super Cache (Free, simple)
- LiteSpeed Cache (Free, if on LiteSpeed server)
Object Caching
// Install Redis or Memcached
// wp-config.php
define('WP_CACHE_KEY_SALT', 'yoursite.com');
Plugins: Redis Object Cache, Memcached Object Cache
3. Database Optimization
Regular Cleanup
-- Delete post revisions
DELETE FROM wp_posts WHERE post_type = 'revision';
-- Delete trash
DELETE FROM wp_posts WHERE post_status = 'trash';
-- Delete spam comments
DELETE FROM wp_comments WHERE comment_approved = 'spam';
-- Optimize tables
OPTIMIZE TABLE wp_posts, wp_postmeta, wp_options;
Plugins: WP-Optimize, Advanced Database Cleaner
wp-config.php Settings
// Limit post revisions
define('WP_POST_REVISIONS', 3);
// Autosave interval (default 60s)
define('AUTOSAVE_INTERVAL', 300);
// Empty trash automatically
define('EMPTY_TRASH_DAYS', 7);
4. Image Optimization
Compress Images Before Upload
- Use TinyPNG, ImageOptim, or Squoosh
- Target: <100KB for most images
Lazy Loading
<!-- Native lazy loading (WordPress 5.5+) -->
<img src="image.jpg" loading="lazy" alt="Description">
Modern Formats
- Convert to WebP (90% smaller than JPEG)
- Use AVIF for even better compression
Plugins: Imagify, ShortPixel, EWWW Image Optimizer, Smush
5. CSS & JavaScript
Minify & Combine
Plugins: WP Rocket, Autoptimize, Asset CleanUp
Defer/Async JavaScript
<!-- Defer non-critical JS -->
<script src="script.js" defer></script>
<!-- Async for independent scripts -->
<script src="analytics.js" async></script>
Remove Unused CSS/JS
- Asset CleanUp (disable scripts per page)
- Remove jQuery if not needed
- Eliminate render-blocking resources
6. CDN (Content Delivery Network)
Popular CDNs
- Cloudflare (Free tier available)
- StackPath
- BunnyCDN (affordable)
- KeyCDN
Benefits
- Faster global delivery
- Reduced server load
- DDoS protection (Cloudflare)
7. Plugin & Theme Optimization
Audit Plugins
- Keep only essential plugins (aim for <20)
- Deactivate and delete unused plugins
- Avoid plugin bloat
Check plugin performance: Query Monitor, P3 Plugin Profiler
Choose Lightweight Themes
Recommended: GeneratePress, Astra, Kadence
Disable Unnecessary Features
// functions.php
// Disable emojis
remove_action('wp_head', 'print_emoji_detection_script', 7);
remove_action('wp_print_styles', 'print_emoji_styles');
// Disable embeds
function disable_embeds() {
wp_deregister_script('wp-embed');
}
add_action('wp_footer', 'disable_embeds');
// Remove query strings
function remove_query_strings() {
if(!is_admin()) {
add_filter('script_loader_src', 'remove_query_strings_split', 15);
add_filter('style_loader_src', 'remove_query_strings_split', 15);
}
}
function remove_query_strings_split($src){
$output = preg_split("/(&ver|\?ver)/", $src);
return $output[0];
}
add_action('init', 'remove_query_strings');
8. Advanced Optimizations
Preload/Prefetch
<!-- Preload critical resources -->
<link rel="preload" href="font.woff2" as="font" type="font/woff2" crossorigin>
<!-- DNS prefetch for external domains -->
<link rel="dns-prefetch" href="//fonts.googleapis.com">
Optimize Fonts
/* Use font-display swap */
@font-face {
font-family: 'CustomFont';
src: url('font.woff2') format('woff2');
font-display: swap;
}
- Limit font weights/styles
- Self-host Google Fonts
- Use system fonts when possible
Heartbeat API Control
// wp-config.php - Reduce Heartbeat frequency
define('WP_HEARTBEAT_INTERVAL', 60);
9. Mobile Optimization
Responsive Design
- Use mobile-first CSS
- Test on real devices
- Optimize tap targets (44×44px minimum)
Reduce Mobile Payload
- Serve smaller images to mobile
- Conditionally load resources
- Simplify mobile design
10. Monitoring & Testing
Speed Testing Tools
- Google PageSpeed Insights
- GTmetrix
- WebPageTest
- Pingdom
Key Metrics (Core Web Vitals)
- LCP (Largest Contentful Paint): <2.5s
- FID (First Input Delay): <100ms
- CLS (Cumulative Layout Shift): <0.1
✅ Quick Wins Checklist
- ☐ Enable page caching
- ☐ Optimize images (compress + WebP)
- ☐ Enable lazy loading
- ☐ Use CDN
- ☐ Minify CSS/JS
- ☐ Enable Gzip compression
- ☐ Update to PHP 8.1+
- ☐ Clean database regularly
- ☐ Remove unused plugins
- ☐ Choose lightweight theme
- ☐ Defer JavaScript
- ☐ Enable browser caching
- ☐ Reduce external HTTP requests
- ☐ Optimize fonts
- ☐ Enable object caching
Essential wp-config.php Tweaks
// Increase memory limit
define('WP_MEMORY_LIMIT', '256M');
// Limit post revisions
define('WP_POST_REVISIONS', 3);
// Disable file editing in admin
define('DISALLOW_FILE_EDIT', true);
// Enable debug mode (disable in production)
define('WP_DEBUG', false);
// Database optimization
define('WP_CACHE', true);
❌ Common Performance Killers
- Too many plugins (>30)
- Unoptimized images (>500KB)
- No caching enabled
- Cheap shared hosting
- Too many external scripts
- Heavy theme/page builder
- No CDN
- Old PHP version (<7.4)
- Database bloat
- Render-blocking CSS/JS
🎯 Target Goal
<2 second page load time | 90+ PageSpeed score
Performance is ongoing – test regularly and optimize iteratively!