Knowledge Base

Performance Optimization Tips

A fast website isn't just nice to have - it's essential. Visitors bounce, search rankings drop, and conversions plummet with every extra second of load time. Let's make your site lightning fast!

Why Speed Matters

  • 53% of visitors leave if a page takes over 3 seconds
  • Google ranks faster sites higher
  • Conversions improve by 7% for every 1-second improvement
  • User experience is dramatically better

Measuring Performance

Essential Tools

Tool What It Tests Best For
Google PageSpeed Insights Performance & Core Web Vitals SEO focus
GTmetrix Load time & waterfall Detailed analysis
Pingdom Load time from locations Geographic testing
WebPageTest Deep performance analysis Advanced users

Key Metrics to Watch

Metric Good Needs Work Poor
LCP (Largest Contentful Paint) < 2.5s 2.5-4s > 4s
FID (First Input Delay) < 100ms 100-300ms > 300ms
CLS (Cumulative Layout Shift) < 0.1 0.1-0.25 > 0.25
TTFB (Time to First Byte) < 200ms 200-500ms > 500ms

[SCREENSHOT: PageSpeed Insights results showing Core Web Vitals]

Server-Side Optimization

1. Use the Latest PHP Version

PHP 8.x is significantly faster than PHP 7.x:

Version Speed Improvement
PHP 7.4 → 8.0 ~10% faster
PHP 7.4 → 8.2 ~20% faster
PHP 7.4 → 8.3 ~25% faster

Upgrade in Enhance: Websites > Your Site > PHP Settings

2. Enable OPcache

OPcache compiles PHP scripts once and caches them:

; In php.ini or .user.ini
opcache.enable=1
opcache.memory_consumption=128
opcache.max_accelerated_files=10000
opcache.validate_timestamps=0  ; Set to 1 during development

3. Choose the Right Web Server

Server Best For
Nginx Static content, high concurrency
LiteSpeed WordPress with LSCache
OpenLiteSpeed Free LiteSpeed alternative
Apache Legacy applications, .htaccess

Switch in Enhance: Websites > Your Site > Settings

4. Enable Server-Level Caching

Configure in Enhance or via .htaccess:

# Browser caching
<IfModule mod_expires.c>
    ExpiresActive On
    ExpiresByType image/jpg "access plus 1 year"
    ExpiresByType image/jpeg "access plus 1 year"
    ExpiresByType image/png "access plus 1 year"
    ExpiresByType image/gif "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"
</IfModule>

5. Enable Gzip/Brotli Compression

Compresses text-based files by 70-90%:

# Gzip compression
<IfModule mod_deflate.c>
    AddOutputFilterByType DEFLATE text/html text/plain text/css
    AddOutputFilterByType DEFLATE application/javascript
    AddOutputFilterByType DEFLATE application/json
    AddOutputFilterByType DEFLATE application/xml
</IfModule>

[SCREENSHOT: Compression settings in Enhance or .htaccess configuration]

Database Optimization

1. Optimise Tables

Regular maintenance keeps your database healthy:

Via phpMyAdmin:

  1. Select all tables
  2. Choose "Optimize table" from dropdown

Via WP-CLI:

wp db optimize

2. Clean Up Database Bloat

Remove unnecessary data:

-- Delete post revisions (WordPress)
DELETE FROM wp_posts WHERE post_type = 'revision';

-- Delete spam comments
DELETE FROM wp_comments WHERE comment_approved = 'spam';

-- Delete transients
DELETE FROM wp_options WHERE option_name LIKE '%_transient_%';

Or use a plugin like WP-Optimize.

3. Add Indexes

Speed up common queries:

-- Check slow queries
SHOW FULL PROCESSLIST;

-- Add index to frequently searched column
ALTER TABLE wp_postmeta ADD INDEX meta_value_index (meta_value(191));

4. Use Object Caching

Redis or Memcached caches database queries:

  1. Enable Redis in Enhance
  2. Install Redis Object Cache plugin (WordPress)
  3. Activate the cache

[SCREENSHOT: Redis enabled in Enhance with connection details]

Image Optimization

Images often account for 50%+ of page weight!

1. Choose the Right Format

Format Best For Compression
WebP Everything (modern browsers) Excellent
JPEG Photographs Good
PNG Graphics with transparency Fair
SVG Icons, logos Perfect (vector)
AVIF Future-proof option Excellent

2. Compress Images

Before uploading:

Automatic WordPress compression:

  • ShortPixel
  • Imagify
  • Smush

3. Responsive Images

Serve appropriately sized images:

<img srcset="image-320.jpg 320w,
             image-640.jpg 640w,
             image-1280.jpg 1280w"
     sizes="(max-width: 320px) 280px,
            (max-width: 640px) 600px,
            1200px"
     src="image-1280.jpg" alt="Description">

4. Lazy Loading

Load images only when visible:

<img src="image.jpg" loading="lazy" alt="Description">

WordPress 5.5+ does this automatically!

Caching Strategies

Page Caching

Serves static HTML instead of running PHP:

WordPress plugins:

  • WP Super Cache (simple)
  • W3 Total Cache (powerful)
  • WP Rocket (premium, excellent)
  • LiteSpeed Cache (for LiteSpeed servers)

Manual caching:

// Start output buffering
ob_start();

// Your page content
echo "Hello World";

// Save to cache file
$cache = ob_get_contents();
file_put_contents('/cache/page.html', $cache);
ob_end_flush();

Browser Caching

Tell browsers to store files locally:

<IfModule mod_headers.c>
    <FilesMatch "\.(ico|jpg|jpeg|png|gif|webp|js|css|woff2)$">
        Header set Cache-Control "max-age=31536000, public"
    </FilesMatch>
</IfModule>

Object Caching

Cache database queries and PHP objects:

// Check cache first
$data = wp_cache_get('my_data', 'my_group');

if (false === $data) {
    // Cache miss - get from database
    $data = expensive_database_query();

    // Store in cache
    wp_cache_set('my_data', $data, 'my_group', 3600);
}

[SCREENSHOT: Caching plugin settings page]

Content Delivery Network (CDN)

A CDN serves your static files from servers worldwide.

Benefits

  • Faster delivery - Files served from nearby servers
  • Reduced server load - Offloads static content
  • DDoS protection - Many CDNs include this
  • Improved availability - Multiple servers = redundancy

Popular CDNs

CDN Free Tier Best For
Cloudflare Yes Most websites
BunnyCDN Trial Cost-effective
KeyCDN Trial Pay-as-you-go
StackPath Trial Enterprise

Setting Up Cloudflare

  1. Sign up at cloudflare.com
  2. Add your website
  3. Update nameservers at your registrar
  4. Configure caching rules
  5. Enable "Auto Minify" and "Brotli"

Code Optimization

Minify CSS & JavaScript

Remove whitespace and comments:

Before:

.button {
    background-color: blue;
    padding: 10px 20px;
    /* This is a button */
}

After:

.button{background-color:blue;padding:10px 20px}

Tools:

  • Autoptimize (WordPress)
  • Build tools (Webpack, Vite, Parcel)

Defer Non-Critical JavaScript

<!-- Defer loading -->
<script src="script.js" defer></script>

<!-- Async loading -->
<script src="analytics.js" async></script>

Critical CSS

Inline above-the-fold CSS:

<head>
    <style>
        /* Critical CSS here - renders immediately */
        .header { ... }
        .hero { ... }
    </style>
    <link rel="stylesheet" href="full.css" media="print" onload="this.media='all'">
</head>

Remove Unused CSS

Tools:

  • PurgeCSS
  • UnCSS
  • Chrome DevTools Coverage tab

WordPress-Specific Tips

1. Limit Post Revisions

// wp-config.php
define('WP_POST_REVISIONS', 5);  // Keep only 5 revisions
// Or disable completely:
define('WP_POST_REVISIONS', false);

2. Increase Memory Limit

// wp-config.php
define('WP_MEMORY_LIMIT', '256M');

3. Disable Pingbacks/Trackbacks

Settings > Discussion > Uncheck pingback/trackback options

4. Use a Lightweight Theme

Theme Type Typical Page Size
Premium bloated theme 3-5 MB
Optimised theme 500 KB - 1 MB
Lightweight theme < 500 KB

Recommended lightweight themes:

  • GeneratePress
  • Astra
  • Kadence

5. Audit Your Plugins

Each plugin adds overhead. Regularly review:

  1. List all plugins
  2. Identify slow ones (Query Monitor plugin helps)
  3. Remove unused plugins
  4. Replace heavy plugins with lighter alternatives

Quick Win Checklist

  • [ ] Upgrade to PHP 8.2+
  • [ ] Enable OPcache
  • [ ] Install caching plugin
  • [ ] Compress images
  • [ ] Enable lazy loading
  • [ ] Minify CSS/JS
  • [ ] Enable Gzip compression
  • [ ] Set up browser caching
  • [ ] Consider a CDN
  • [ ] Optimise database
  • [ ] Remove unused plugins
  • [ ] Use efficient theme

Before & After Example

Metric Before After Improvement
Page Size 4.2 MB 850 KB 80% smaller
Load Time 8.5s 1.8s 79% faster
Requests 95 28 71% fewer
PageSpeed Score 34 92 171% better

[SCREENSHOT: Before and after PageSpeed scores]


Need more help? Browse our other Knowledge Base articles or contact our support team!

Please rate this article to help us improve our Knowledge Base.

0 0