Перейти к содержимому
Skip to content
← All articles

Website Speed Optimization: A Complete Guide

Website loading speed is one of the key factors that determines user experience, conversion rates, and search engine rankings. According to Google, if a page takes longer than 3 seconds to load, more than 50% of mobile users will leave it. In this guide, we will thoroughly cover all aspects of speed optimization — from the server side to client-side rendering.

Core Web Vitals: Key Performance Metrics

In 2021, Google introduced PageSpeed анализ as an official ranking factor. These metrics reflect real user experience and are measured under field conditions.

LCP — Largest Contentful Paint

LCP measures the time it takes for the largest visible element on a page to render. This could be a banner image, video, or a large block of text. The target value is under 2.5 seconds.

Main causes of poor LCP:

FID and INP — Interface Responsiveness

FID (First Input Delay) measured the delay of the user's first interaction. Since March 2024, it has been replaced by INP (Interaction to Next Paint), which evaluates responsiveness throughout the entire session. The target INP value is under 200 milliseconds.

To improve INP:

CLS — Cumulative Layout Shift

CLS measures the visual stability of a page. Layout shifts frustrate users — they accidentally click the wrong elements or lose their reading position. The target value is under 0.1.

How to prevent layout shifts:

TTFB — Time to First Byte

TTFB measures the time from sending a request to receiving the first byte of the server's response. This is a foundational metric that affects all other performance indicators. The recommended value is under 800 ms, ideally under 200 ms.

Factors affecting TTFB:

FactorImpactSolution
Distance to serverHigh latency for remote usersCDN, edge servers
Server processingSlow DB queries, heavy computationsCaching, query optimization
TLS handshakeAdditional round tripsTLS 1.3, OCSP stapling, HTTP/2
RedirectsEach redirect adds to TTFBMinimize redirect chains

You can check your site's TTFB using the enterno.io HTTP header checker tool — it shows server response time and all caching headers.

Image Optimization

Images typically account for 40–60% of total page weight. Optimizing them is the fastest way to speed up your site.

Modern Formats

WebP provides 25–35% better compression than JPEG at comparable quality. AVIF is an even more efficient format, compressing images 50% better than JPEG. Use the <picture> element for progressive enhancement:

<picture>
  <source srcset="image.avif" type="image/avif">
  <source srcset="image.webp" type="image/webp">
  <img src="image.jpg" alt="Description" width="800" height="600" loading="lazy">
</picture>

Lazy Loading

The loading="lazy" attribute defers loading of images outside the visible area. However, for the LCP element (main banner), use loading="eager" and add fetchpriority="high".

Responsive Images

The srcset attribute allows the browser to choose the optimal image size based on the screen. Don't load a 2000-pixel image on a mobile phone with a 375-pixel screen.

Resource Minification and Compression

Minification removes whitespace, comments, and shortens variable names from code. This reduces file sizes by 20–40%.

In addition to minification, configure server-side compression. Gzip reduces text resource sizes by 70–80%, and Brotli by 80–90%. Check for the Content-Encoding: br or Content-Encoding: gzip header using the HTTP header analyzer.

CDN — Content Delivery Network

A CDN places copies of your content on servers around the world. Users receive data from the nearest server, significantly reducing latency. Learn more about how CDNs work in our dedicated article.

CDN benefits:

Caching

Properly configured caching is one of the most effective ways to speed up repeat visits.

HTTP Caching

The Cache-Control header manages caching at the browser and intermediate proxy level. Recommended strategies:

Resource TypeRecommended Cache-Control
Static resources with hashmax-age=31536000, immutable
HTML pagesno-cache (with ETag validation)
API документацию responsesno-store or short max-age
Images without hashmax-age=86400, stale-while-revalidate=604800

Server-Side Caching

On the server side, use:

JavaScript Optimization

JavaScript is the primary source of client-side performance issues. Every kilobyte of JS requires downloading, parsing, compiling, and executing.

Code Splitting

Split your bundle into parts, loading only the code needed for the current page. Dynamic import() allows loading modules on demand:

// Load module only when needed
const module = await import('./heavy-module.js');
module.init();

Tree Shaking

Ensure your bundler (webpack, Rollup, esbuild) removes unused code. Use ES modules (import/export) instead of CommonJS (require) for this to work.

Deferred Script Loading

Use async and defer attributes for scripts that are not critical to initial rendering. Analytics scripts, chat widgets, and social plugins should load after the main content.

Font Optimization

Web fonts can significantly slow down text rendering. Recommendations:

HTTP/2 and HTTP/3

HTTP/2 supports multiplexing — loading multiple resources over a single connection. HTTP/3 (based on QUIC) is even faster thanks to eliminating head-of-line blocking and built-in TLS 1.3.

Ensure your server supports at least HTTP/2. You can check the protocol using the enterno.io HTTP header analyzer.

Monitoring Tools

Regularly track your site's performance using:

Optimization Checklist

  1. Check TTFB — it should be under 200 ms
  2. Configure Brotli/Gzip compression
  3. Optimize and convert images to WebP/AVIF
  4. Add lazy loading for off-screen images
  5. Minify CSS, JS, and HTML
  6. Configure Cache-Control for all resource types
  7. Implement code splitting for JavaScript
  8. Connect a CDN
  9. Optimize font loading
  10. Eliminate redirect chains
  11. Upgrade server protocol to HTTP/2 or HTTP/3
  12. Set up performance monitoring

Try It Yourself

Use the enterno.io HTTP header checker tool to analyze your site's server response time and caching headers.

Check your website right now

Check now →
More articles: Performance
Performance
Content Delivery Optimization: CDN Strategies and Edge Computing
16.03.2026 · 11 views
Performance
Web Performance Budgets: Setting, Enforcing, and Automating Performance Limits
16.03.2026 · 12 views
Performance
Graceful Degradation vs Progressive Enhancement: Strategies and Real-World Examples
16.03.2026 · 15 views
Performance
Image Optimization for Web Performance
14.03.2026 · 18 views