Coding

How to make your website load fast

By Ali Ghafori · 3 min read

Speed isn't a luxury for a website. Visitors leave slow pages, especially on mobile connections, and Google uses page experience signals as part of how it ranks sites. Fortunately, most slow websites are slow for the same few reasons, and fixing them doesn't require advanced engineering. Here's where to look and what to do.

Measure first

Don't guess — measure. Free tools show exactly what's slowing a page down:

Understand Core Web Vitals

Google summarizes the user experience with three metrics:

1. Optimize images — usually the biggest win

Images are typically the heaviest part of a page. A single photo straight from a camera or AI generator can be several megabytes.

<img src="/images/work.webp" width="800" height="500"
     alt="Edited video project timeline" loading="lazy">

2. Reduce JavaScript

JavaScript is expensive: it must be downloaded, parsed and executed, which hurts both loading and responsiveness, especially on cheaper phones.

3. Keep CSS lean and fonts under control

4. Turn on compression and caching

On the server, compress text files and let browsers cache static files. In Nginx:

gzip on;
gzip_types text/css application/javascript image/svg+xml;

location ~* \.(css|js|webp|avif|jpg|png|svg|woff2)$ {
    expires 30d;
    add_header Cache-Control "public";
}

When you change a cached file, change its name (for example style.v2.css) so browsers download the new version.

5. Use HTTP/2 and a CDN

HTTP/2 (or HTTP/3) lets the browser download many files over one connection efficiently — enable it on your web server; it requires HTTPS. A CDN stores copies of your site in data centers around the world, so visitors download from somewhere nearby. For a global audience, a CDN is one of the easiest big improvements.

6. Make the server respond quickly

If the first byte of HTML takes a long time to arrive, everything else waits. Static sites are naturally fast here. For dynamic sites, use page caching, keep the database tuned, and make sure the server isn't overloaded.

7. Prioritize what's above the fold

Help the browser show the visible part of the page first: keep the main image small and preloaded if needed, avoid render-blocking scripts in the <head>, and don't hide content behind animations that wait for JavaScript.

Checklist

Measure with PageSpeed Insights · resize, compress and convert images to WebP · set image dimensions · lazy-load below-the-fold images · cut unnecessary JavaScript and third-party scripts · limit fonts · enable compression and caching · use HTTP/2 and a CDN. Work through these in order and most sites go from sluggish to fast.

← Back to all articles