Essentials
Performance
Website performance is a set of factors that determine the loading speed, responsiveness, and smoothness of a web application. The main goal is to make interaction fast and unnoticeable for the user.
Main Metrics (Navigation Timing API)
- Network — time for connection establishment, DNS, TLS, resource loading.
- Server Response Time — time for the server to respond to the first request.
- Render Blocking — delays due to CSS/JS affecting the first paint.
- First Contentful Paint (FCP) — time until the first content appears.
- Largest Contentful Paint (LCP) — time until the main element of the page appears.
- Time To Interactive (TTI) — the moment the page is ready for interaction.
- Response Latency — response time to user actions.
- Smoothness — FPS stability, smoothness of scrolling and animations.
Navigation metrics can be measured via Navigation Timing API, performance.now(), DevTools → Performance.
User Perception of Time
- < 100 ms — instantaneous (felt immediately).
- < 1 s — comfortable.
- 1–2 s — acceptable, but attention drops.
- 2 s — user loses focus.
- Active waiting (loader, skeleton) is perceived better than passive.
Key Sources of Slowdowns
- Network: slow DNS, lack of cache, heavy resources.
- Server: slow rendering or API response.
- Browser: blocking scripts, heavy JS logic, layout/reflow.
- Runtime: frequent repaints, heavy loops, inefficient events.
Optimization Techniques
HTTP Level
- Minification & Compression — minimization and
gzip/brotli. - Caching —
Cache-Control,ETag,Service Worker. - CDN & Sprites — reducing latency and number of requests.
Scripts
async/deferfor non-blocking loading.- Code splitting — dividing JS into chunks.
- Lazy loading of modules and heavy computations.
- Removing unused scripts (
Coveragein DevTools).
Rendering
- Inline-CSS for critical-path.
- Minimize reflow/repaint.
- Use
will-changeandtransforminstead oftop/left.
Images & Fonts
- Optimization of formats (
webp,avif,woff2). srcset,sizes,fetchpriority,loading="lazy".- Minimizing the number of custom fonts.
Preload / Prefetch / Preconnect
preload— for critical resources.prefetch— for future pages.preconnect— early opening of connections.
Analysis Tools
High-level:
- Lighthouse (PageSpeed Insights, DevTools Audit).
Low-level:
- DevTools → Network, Performance, Rendering, Memory, Coverage, Profiler.
- Metrics:
performance.timing,PerformanceObserver.
Key Ideas
- Performance = loading speed + responsiveness + smoothness.
- It is important to optimize not only the network but also the runtime.
- A UX indicator is when the user doesn't notice speed problems.
- Use DevTools and Lighthouse for constant control.
- Every optimization is a struggle for milliseconds and user attention.