Blog

Web Development articles

Website Speed Optimization: 15 Practical Fixes

Fifteen practical website speed optimization fixes for images, code, fonts, caching and servers, with notes on how to check each one is working.

4 min read Web Development

A slow website costs you visitors before they have read a word. People abandon pages that take too long, and search engines take page experience into account. The good news is that most slow sites suffer from the same handful of problems, and many fixes are straightforward. Here are fifteen practical website speed optimization fixes, grouped by where the time is lost, with a note on how to verify each one.

Website speed optimization starts with measurement

Test a few important pages (home, a product or service page, a landing page) with a lab tool such as Lighthouse in Chrome DevTools or PageSpeed Insights, and note the results. Test on a throttled mobile connection, because that is where problems show most. Re-test after each change so you know what actually helped.

Images

1. Resize images to the size they are displayed

A photo straight from a camera can be thousands of pixels wide and several megabytes, then shown at 600 pixels. Export images at the largest size they will actually appear, and use the srcset attribute so phones download smaller versions than desktops.

2. Use modern formats

WebP and AVIF typically produce noticeably smaller files than JPEG or PNG at similar visual quality, and are supported by current major browsers. Many image tools and CDNs can convert automatically.

3. Lazy-load images below the fold

Add loading="lazy" to images further down the page so they load only as the visitor scrolls. Do not lazy-load the main image at the top of the page, which should load as early as possible.

4. Always set width and height

Giving images (and video and ad slots) explicit dimensions lets the browser reserve space, so text does not jump around as images arrive. That improves both perceived speed and layout stability.

Code and assets

5. Defer non-critical JavaScript

Scripts in the page head can block the page from appearing. Mark scripts that are not needed for the first view with defer or async, so HTML can be displayed while they download.

6. Remove what you do not use

Old plugins, unused libraries, abandoned tracking scripts and full icon sets for three icons all add weight. The Coverage panel in Chrome DevTools shows how much downloaded CSS and JavaScript is never used on a page.

7. Audit third-party scripts

Chat widgets, analytics, heatmaps, social embeds and ad tags each add requests and processing, often from servers you do not control. Keep only those that earn their place, and load them after the main content where possible.

8. Minify and bundle sensibly

Minification strips whitespace and comments from CSS and JavaScript. Modern build tools do this automatically; make sure production builds are actually being deployed rather than development builds.

Fonts

9. Limit and optimise web fonts

Each font weight and style is a separate file. Use as few as the design genuinely needs, prefer the compact WOFF2 format, and set font-display: swap so text appears immediately in a fallback font instead of staying invisible while the custom font loads. Preloading the one or two most important font files can also help.

Caching and delivery

10. Enable text compression

Servers can compress HTML, CSS, JavaScript and JSON with gzip or Brotli before sending them, often shrinking text files substantially. Check the Content-Encoding response header with our HTTP header checker to confirm compression is on.

11. Set browser caching headers

Static files such as images, CSS and JavaScript rarely change. A long Cache-Control lifetime lets returning visitors reuse them without downloading again. Use versioned filenames (for example app.3f9a1c.js) so that when you do change a file, browsers fetch the new one.

12. Use a content delivery network

A CDN stores copies of your static files on servers around the world, so visitors download them from somewhere nearby. If your audience is international, a CDN is one of the most effective single improvements. Most CDNs also support HTTP/2 and HTTP/3, which handle many small files more efficiently than older HTTP versions.

Server and backend

13. Reduce server response time

If the server takes a long time to produce the HTML, nothing else can start. Measure time to first byte (TTFB). Causes of slow responses include underpowered or overloaded hosting, missing PHP opcode caching, slow database queries and doing too much work on every request.

14. Cache pages and queries

Pages that are the same for every visitor can be cached as finished HTML and served without running application code. For dynamic applications, cache the results of expensive database queries or API calls for a short period. Even a cache lasting a minute can dramatically reduce load on a busy page.

15. Optimise the database

Missing indexes, queries inside loops and ever-growing tables of logs or sessions are common culprits on database-driven sites. Enable slow query logging, fix the worst offenders and clean up old data. Our database management and server management services handle this kind of tuning, but many fixes are within reach of any competent developer.

Prioritising the fixes

SymptomLikely fixes to try first
Long wait before anything appears13, 14, 15, 5
Page appears but main image is slow1, 2, 12, and do not lazy-load it (3)
Content jumps around while loading4, 9
Page is visible but sluggish to respond6, 7, 8
Slow for distant visitors only12, 11, 10

Keep it fast

Speed tends to decay as new plugins, scripts and images are added. Make performance part of your release routine: set a budget for page weight, re-test key pages after significant changes, and review third-party scripts every few months. Field data from real users, available in Google Search Console for sites with enough traffic, shows whether improvements in the lab are reaching actual visitors.

Key takeaways

  • Measure before and after every change, on mobile.
  • Images and third-party scripts are the most common sources of avoidable weight.
  • Compression, caching headers and a CDN speed up delivery for everyone.
  • A slow server or database delays everything else, so check response time early.

Need help with this?

Netifi helps businesses around the world with Web Development. Tell us what you are working on.