Logo
Bearhost Logo

How to Optimize Website Loading Speed

By Elliot, BearHost·

Website speed directly affects user experience, search rankings, and conversion rates. Google uses Core Web Vitals as a ranking factor, so a fast site is essential for SEO.

Benchmark Your Current Speed

Before making changes, measure your baseline:

  • PageSpeed Insights — Google's tool with Core Web Vitals scores
  • GTmetrix — Detailed waterfall analysis and recommendations
  • Core Web Vitals to aim for:
    • LCP (Largest Contentful Paint): Under 2.5 seconds
    • INP (Interaction to Next Paint): Under 200 milliseconds
    • CLS (Cumulative Layout Shift): Under 0.1

Enable Gzip Compression

Gzip compresses text-based files (HTML, CSS, JS) before sending them to the browser, reducing file sizes by 60–80%.

Add to your .htaccess file:

<IfModule mod_deflate.c>
  AddOutputFilterByType DEFLATE text/html
  AddOutputFilterByType DEFLATE text/css
  AddOutputFilterByType DEFLATE text/javascript
  AddOutputFilterByType DEFLATE application/javascript
  AddOutputFilterByType DEFLATE application/json
  AddOutputFilterByType DEFLATE application/xml
  AddOutputFilterByType DEFLATE image/svg+xml
  AddOutputFilterByType DEFLATE font/woff2
</IfModule>

Enable Browser Caching

Browser caching tells visitors' browsers to store static files locally, so repeat visits load much faster.

Add to .htaccess:

<IfModule mod_expires.c>
  ExpiresActive On
  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 image/svg+xml "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"
  ExpiresByType text/html "access plus 0 seconds"
</IfModule>

Optimise Images

Images are usually the largest files on a page. Optimising them has the biggest impact.

Convert to WebP

WebP format is 25–35% smaller than JPEG/PNG with the same quality.

  • ShortPixel (WordPress plugin) — automatically converts and serves WebP
  • Imagify — bulk optimise existing images
  • EWWW Image Optimizer — free option with WebP conversion

Resize Images

Do not upload 4000px wide images if they display at 800px. Resize before uploading or use a plugin that serves responsive images.

Lazy Loading

Lazy loading defers offscreen images until the user scrolls to them. WordPress enables this by default for images. For additional control, use the WP Rocket or Autoptimize plugin.

Minify CSS and JavaScript

Minification removes whitespace, comments, and unnecessary characters from code files.

Using Autoptimize (Free WordPress Plugin)

  1. Install Autoptimize
  2. Go to Settings > Autoptimize
  3. Check:
    • Optimise JavaScript Code
    • Optimise CSS Code
    • Optimise HTML Code
  4. Click Save Changes and Empty Cache

Set Up a CDN

A Content Delivery Network serves your files from servers worldwide, reducing latency for visitors far from your server.

Cloudflare Free CDN

  1. Sign up at cloudflare.com
  2. Add your domain and follow the setup wizard
  3. Update your nameservers
  4. Enable Auto Minify for JavaScript, CSS, and HTML
  5. Enable Brotli compression
  6. Set Browser Cache TTL to 1 month

Cloudflare's free plan provides CDN, basic DDoS protection, and SSL.

Database Optimisation

A bloated database slows down every page load.

  1. Install WP-Optimize
  2. Clean post revisions, transients, spam comments, and trashed items
  3. Schedule weekly automatic cleanups
  4. See our dedicated database optimisation guide for details

PHP OPcache

OPcache stores compiled PHP code in memory, eliminating recompilation on every request. It is usually enabled by default on BearHost servers.

Verify in cPanel > MultiPHP INI Editor:

opcache.enable = 1
opcache.memory_consumption = 128
opcache.max_accelerated_files = 10000
opcache.revalidate_freq = 60

Quick Wins Checklist

| Action | Impact | Difficulty | |---|---|---| | Enable Gzip compression | High | Easy | | Optimise and compress images | High | Easy | | Enable browser caching | Medium | Easy | | Set up Cloudflare CDN | High | Easy | | Minify CSS/JS (Autoptimize) | Medium | Easy | | Lazy load images | Medium | Easy | | Clean database (WP-Optimize) | Medium | Easy | | Reduce active plugins | Medium | Medium | | Use a caching plugin | High | Medium | | Upgrade PHP version | Medium | Easy | | Optimise web fonts | Low | Medium | | Defer non-critical JavaScript | Medium | Medium |

Caching Plugins

If your server uses LiteSpeed (common on BearHost shared hosting):

  • Use LiteSpeed Cache plugin (free, best performance on LiteSpeed servers)

If your server uses Apache:

  • Use WP Super Cache (free, simple)
  • Use W3 Total Cache (free, more options)
  • Use WP Rocket (paid, easiest to configure)

After Optimising

Re-test your site with PageSpeed Insights and GTmetrix. Compare scores to your baseline. Most sites see a 30–60% improvement after implementing these changes.

Tags:#performance#speed#optimization#caching#compression#cdn#images#core-web-vitals