Table of contents
Why website speed matters
1. User expectations
Users expect a page to appear almost at once:
- In Google's 2016 DoubleClick study, 53% of mobile site visits were likely to be abandoned when pages took longer than 3 seconds to load
2. SEO ranking factor
Google's ranking systems use the Core Web Vitals as part of page experience, which rolled out in 2021. Relevant content still comes first, so a fast page does not outrank a better answer, but a slow page gives away ground against similar pages.
3. Conversion rate
Speed affects revenue, and you can see it in your own data: record your conversion rate before each optimization and compare it afterwards.
Core Web Vitals explained
Google measures user experience with three Core Web Vitals:
1. Largest Contentful Paint (LCP)
What it measures: How quickly the largest visible content block loads
Target value: at most 2.5 seconds
Optimization:
- Optimize images and use lazy loading
- Use fast hosting
- Inline critical CSS
- Eliminate render-blocking resources
2. Interaction to Next Paint (INP)
What it measures: How quickly the page responds to clicks, taps and key presses during the whole visit. INP replaced First Input Delay (FID) as a Core Web Vital on 12 March 2024.
Target value: at most 200 milliseconds
Optimization:
- Reduce JavaScript execution time
- Use code splitting
- Break up long tasks
- Move heavy computations to Web Workers
3. Cumulative Layout Shift (CLS)
What it measures: Visual stability during loading
Target value: at most 0.1
Optimization:
- Specify width/height for images and videos
- Don't insert dynamic content above existing content
- Load web fonts with font-display: swap
- Reserve space for ads
Measuring performance
Performance testing tools
1. Google PageSpeed Insights
URL: pagespeed.web.dev
Benefits: Shows Core Web Vitals, provides specific optimization suggestions, free
2. GTmetrix
URL: gtmetrix.com
Benefits: Detailed waterfall charts, video recording of load process, historical data
3. WebPageTest
URL: webpagetest.org
Benefits: Tests from different locations, various browsers, advanced metrics
4. Chrome DevTools (Lighthouse)
Access: F12 → Lighthouse tab
Benefits: Local testing, detailed performance analysis, free. Lighthouse runs in the lab and cannot measure INP, so watch Total Blocking Time (TBT) as a stand-in.
The optimizations that matter most
1. Implement caching
Caching is the most effective optimization on this list. It cuts server load and loading times at several layers:
- Browser caching keeps static resources in the visitor's browser
- Server caching with Redis or Memcached handles dynamic content
- CDN caching serves your content from a Content Delivery Network around the world
- Database caching stores query results
2. Minification and compression
You can shrink file sizes in four ways:
- Gzip or Brotli compresses text files such as HTML, CSS and JavaScript
- Minifying CSS and JS removes whitespace and comments
- Tree shaking removes unused code
- Code splitting loads only the code a page needs
3. Optimize the critical rendering path
These steps get the first render on screen sooner:
- Inline the critical CSS directly in the HTML
- Defer non-critical JavaScript so it loads later
- Preload important resources with <link rel="preload">
- Use DNS prefetch to resolve domains in advance
Image optimization
Images are often the heaviest part of a page, so this is where you can save the most:
Use modern image formats
- WebP: lossy WebP files are 25-34% smaller than comparable JPEGs, according to Google, and support transparency
Supported by all current major browsers - AVIF: usually compresses even better than WebP
Supported by current versions of Chrome, Edge, Firefox and Safari - SVG: for logos, icons and other graphics
Scales without quality loss
Responsive images
Deliver the right image size for each device:
- Use
srcsetandsizesattributes - Use the picture element for art direction
- Lazy loading for below-the-fold images
- Show a placeholder (LQIP, Low Quality Image Placeholder)
Image optimization tools
TinyPNG
Intelligent PNG/JPEG compression
ImageOptim
Mac app for lossless optimization
Squoosh
Google's web-based optimizer
Cloudinary
Automatic image optimization (cloud)
Code optimization
JavaScript performance
-
Load scripts with defer or async so they don't block rendering
<script defer src="app.js"></script> -
Split your code with dynamic imports
const module = await import('./module.js') - Use tree shaking to eliminate unused code
- Skip jQuery and use vanilla JS or a modern framework instead
CSS performance
- Inline the above-the-fold styles in the <head>
- Purge unused CSS (Tailwind, Bootstrap)
- Use CSS containment to isolate rendering areas
- Avoid @import, because it blocks parallel loading
Server and hosting
Choosing hosting
Your choice of hosting affects speed more than you might expect:
- Shared hosting is slow, and its performance is unpredictable
- VPS or cloud hosting performs better and scales with you
- Managed WordPress hosting is tuned for WordPress (WP Engine, Kinsta)
- Jamstack hosting gives the best performance (Vercel, Netlify, Cloudflare Pages)
CDN (Content Delivery Network)
A CDN serves your content from servers around the world, which cuts latency:
Cloudflare
Free plan, global, DDoS protection
Fastly
Enterprise-level, real-time purging
AWS CloudFront
AWS integration, pay-as-you-go
BunnyCDN
Affordable, fast, easy setup
HTTP/2 and HTTP/3
The newer protocols load pages faster:
- Multiplexing sends multiple requests over one connection
- 103 Early Hints tell the browser about critical resources early (Chrome turned off HTTP/2 Server Push with version 106 in 2022)
- Header compression reduces overhead
- HTTP/3 (QUIC) is faster again and copes better with packet loss
Mobile performance
On many websites most visitors arrive on a phone, and Google indexes the mobile version of your pages, so build and optimize for phones first:
Mobile-specific optimizations
- Serve smaller images, because a phone doesn't need 4K resolution
- Make touch targets large enough and keep event handlers fast, so every tap gets a quick response
- Add a service worker for offline functionality and caching
- Use adaptive loading to ship fewer features on slow connections
Network Information API
Adapt content to connection quality:
- Reduced image quality on 3G
- Disabled autoplay videos on slow connections
- More aggressive lazy loading on mobile
Continuous monitoring
A site gets slower as its code and content grow, so you need to keep measuring:
Real user monitoring (RUM)
Measure what real visitors experience:
- Google Analytics 4, if you send Web Vitals as events with Google's web-vitals library
- Search Console, with its Core Web Vitals report
- SpeedCurve for detailed RUM and monitoring
- New Relic for application performance monitoring
Performance budget
Set limits for your website:
- Max. 200 KB JavaScript
- Max. 100 KB CSS
- Max. 2 MB images (total, above-the-fold)
- LCP at most 2.5 s, INP at most 200 ms, CLS at most 0.1
10 quick wins for immediate improvements
- 1. Compress images (TinyPNG)
- 2. Enable Gzip/Brotli compression
- 3. Set up browser caching
- 4. Enable lazy loading for images
- 5. Remove unused CSS
- 6. Use defer/async for JavaScript
- 7. Use a CDN (Cloudflare has a free plan)
- 8. Use modern image formats (WebP)
- 9. Reduce plugins/extensions
- 10. Optimize database queries
7 common performance mistakes
- 1. Too many plugins/third-party scripts
- 2. Non-optimized images (uploading original size)
- 3. No caching implemented
- 4. Render-blocking CSS/JS in <head>
- 5. Shared hosting for high-traffic sites
- 6. Loading all images on every page (no lazy loading)
- 7. Not monitoring performance after launch
Website speed: where to start
Website performance has a direct effect on user experience, SEO rankings, and conversions. The tools above give you clear numbers to work from.
Start with the quick wins, measure what changed, and keep going from there, because the milliseconds you save on each page view add up.
Next step: Test your website with PageSpeed Insights and implement the top 3 recommendations this week.
Sources & references
We checked and used these sources for this article:
Documentation
- 01
- 02
- 03
- 04
- 05
- 06
Research
- 01
Need help with performance optimization?
We find what slows your website down and fix it, with your Core Web Vitals as the yardstick.
Book a free first consultation →