Practical tips and techniques to drastically improve your website loading time. From image optimization to caching, CDN usage, and code minification.
Page loading time directly impacts user experience, conversion rates, and Google rankings. Studies show that 53% of mobile users abandon a site if it takes longer than 3 seconds to load. Each additional second of loading time can reduce conversion rates by up to 7%.
Google has used page speed as a ranking factor for desktop since 2010 and for mobile search results since 2018. With the introduction of Core Web Vitals in 2021, performance has become even more heavily weighted.
Images often account for 50–70% of total page weight. Here are the key measures:
srcset attribute to serve different image sizes for different screens.loading="lazy" attribute makes this possible without JavaScript.<img src="photo.webp"
srcset="photo-400.webp 400w, photo-800.webp 800w, photo-1200.webp 1200w"
sizes="(max-width: 600px) 400px, (max-width: 1000px) 800px, 1200px"
loading="lazy"
alt="Description of the image"
width="800" height="600">
Proper caching means returning visitors do not have to re-download all resources. Set cache headers for static files:
Cache-Control: public, max-age=31536000, immutable — cache for one year when you use versioning in file names (e.g., style.v3.css).Cache-Control: no-cache — always check with the server for a new version.Gzip or Brotli compression reduces the transfer size of text resources by 60–80%. Most web servers support this out of the box — it just needs to be enabled.
Brotli offers 15–20% better compression than Gzip and is supported by all modern browsers. In Apache configuration:
# Apache - Enable Brotli
<IfModule mod_brotli.c>
AddOutputFilterByType BROTLI_COMPRESS text/html text/css
AddOutputFilterByType BROTLI_COMPRESS application/javascript application/json
AddOutputFilterByType BROTLI_COMPRESS image/svg+xml
</IfModule>
Minification removes unnecessary whitespace, comments, and line breaks from your code. This typically reduces file size by 10–30%.
<head> as inline CSS.A CDN distributes your static content across servers worldwide, so users load data from the nearest location. This significantly reduces latency, especially for international visitors.
Popular CDN providers include Cloudflare (free tier available), Bunny CDN, AWS CloudFront, and Fastly. Cloudflare also offers automatic image optimization, Brotli compression, and DDoS protection.
JavaScript and CSS in the <head> block page rendering. Here is how to avoid that:
defer or async for script tags. defer is usually the better choice as it preserves execution order.media="print" onload="this.media='all'" pattern.font-display: swap and <link rel="preconnect"> for external font servers.Time to First Byte (TTFB) should be under 200ms. Measures to improve it:
Every external script (analytics, chatbots, social media widgets, ads) costs loading time. Ask critically:
Tip: Load tracking scripts only after cookie consent. This improves not only performance but also privacy compliance.
Optimization is an ongoing process. Use these tools to regularly check your speed:
Test your website performance for free with PageScore and get actionable optimization suggestions.