Web Performance
Web performance is the objective measurements and the perceived user experience of load time and runtime. Web performance is how long a site takes to load, become interactive and responsive, and how smooth the content is during user interactions - is the scrolling smooth? are buttons clickable? Are pop-ups quick to load and display, and do they animate smoothly as they do so? Web performance includes both objective measurements like time to load, frames per second, and time to become interactive, and subjective experiences of how long it felt like it took the content to load.
The longer it takes for a site to respond, the more users will abandon the site. It is important to minimize the loading and response times and add additional features to conceal latency by making the experience as available and interactive as possible, as soon as possible, while asynchronously loading in the longer tail parts of the experience.
There are tools, APIs, and best practices that help us measure and improve web performance. We cover them in this section:
Key performance guides
- 대기 시간(Latency) 이해하기
대기 시간(Latency) 이란 하나의 데이터 패킷이 출발지에서 도착지까지 가는 데 걸리는 시간을 뜻합니다. 성능 최적화에 있어서 대기 시간의 원인을 줄이는 것과 연결 상태가 좋지 않은 사용자를 고려하여 대기 시간이 긴 환경에서 사이트 성능을 테스트하는 것은 중요합니다. 이 글에서 대기 시간이 무엇인지, 대기 시간이 성능에 어떤 영향을 주는지, 이를 어떻게 측정하고 어떤 방법으로 줄일 수 있을지에 관해 설명합니다.
- 웹페이지를 표시한다는 것: 브라우저는 어떻게 동작하는가
사용자는 로드가 빠르고 상호작용이 원활한 컨텐츠로 이루어진 웹 경험을 원합니다. 따라서 개발자는 이 두 가지 목표를 달성하기 위해서 부단히 노력해야합니다.
- 중요 렌더링 경로
중요 렌더링 경로 (Critical Rendering Path)는 브라우저가 HTML, CSS, Javascript를 화면에 픽셀로 변화하는 일련의 단계를 말하며 이를 최적화하는 것은 렌더링 성능을 향상시킵니다. 중요 렌더링 경로는 Document Object Model (DOM), CSS Object Model (CSSOM), 렌더 트리 그리고 레이아웃을 포함합니다.
Beginner's tutorials
The MDN Web Performance Learning Area contains modern, up-to-date tutorials covering Performance essentials. Start here if you are a newcomer to performance:
- Web performance: brief overview
-
Overview of the web performance learning path. Start your journey here.
- What is web performance?
-
This article starts the module off with a good look at what performance actually is — this includes the tools, metrics, APIs, networks, and groups of people we need to consider when thinking about performance, and how we can make performance part of our web development workflow.
- How do users perceive performance?
-
More important than how fast your website is in milliseconds, is how fast your users perceive your site to be. These perceptions are impacted by actual page load time, idling, responsiveness to user interaction, and the smoothness of scrolling and other animations. In this article, we discuss the various loading metrics, animation, and responsiveness metrics, along with best practices to improve user perception, if not the actual timings.
- Web performance basics
-
In addition to the front end components of HTML, CSS, JavaScript, and media files, there are features that can make applications slower and features that can make applications subjectively and objectively faster. There are many APIs, developer tools, best practices, and bad practices relating to web performance. Here we'll introduce many of these features ad the basic level and provide links to deeper dives to improve performance for each topic.
- HTML performance features
-
Some attributes and the source order of your mark-up can impact the performance or your website. By minimizing the number of DOM nodes, making sure the best order and attributes are used for including content such as styles, scripts, media, and third-party scripts, you can drastically improve the user experience. This article looks in detail at how HTML can be used to ensure maximum performance.
- Multimedia: images and video
-
The lowest hanging fruit of web performance is often media optimization. Serving different media files based on each user agent's capability, size, and pixel density is possible. Additional tips like removing audio tracks from background videos can improve performance even further. In this article we discuss the impact video, audio, and image content has on performance, and the methods to ensure that impact is as minimal as possible.
- CSS performance features
-
CSS may be a less important optimization focus for improved performance, but there are some CSS features that impact performance more than others. In this article we look at some CSS properties that impact performance and suggested ways of handling styles to ensure performance is not negatively impacted.
- JavaScript performance best practices
-
JavaScript, when used properly, can allow for interactive and immersive web experiences — or it can significantly harm download time, render time, in-app performance, battery life, and user experience. This article outlines some JavaScript best practices that should be considered to ensure even complex content is as performant as possible.
- Mobile performance
-
With web access on mobile devices being so popular, and all mobile platforms having fully-fledged web browsers, but possibly limited bandwidth, CPU and battery life, it is important to consider the performance of your web content on these platforms. This article looks at mobile-specific performance considerations.
Using Performance APIs
- Performance API
-
This guide describes how to use the
Performance
interfaces that are defined in the High-Resolution Time standard. - Resource Timing API
-
Resource loading and timing the loading of those resources, including managing the resource buffer and coping with CORS
- The performance timeline
-
The Performance Timeline standard defines extensions to the
Performance
interface to support client-side latency measurements within applications. Together, these interfaces can be used to help identify an application's performance bottlenecks. - User Timing API
-
Create application specific timestamps using the user timing API's "mark" and "measure" entry types - that are part of the browser's performance timeline.
- Beacon API
-
The Beacon interface schedules an asynchronous and non-blocking request to a web server.
- Intersection Observer API
-
Learn to time element visibility with the Intersection Observer API and be asynchronously notified when elements of interest becomes visible.
Other documentation
- Firefox Profiler Performance Features
-
This website provides information on how to use and understand the performance features in your developer tools, including Call Tree, Flame Graph, Stack Chart, Marker Chart and Network Chart.
- Profiling with the built-in profiler
-
Learn how to profile app performance with Firefox's built-in profiler.
Glossary Terms
- Beacon (en-US)
- Brotli compression (en-US)
- Client hints
- Code splitting
- CSSOM (en-US)
- Domain sharding (en-US)
- Effective connection type (en-US)
- First contentful paint (en-US)
- First CPU idle (en-US)
- First input delay (en-US)
- First interactive (en-US)
- First meaningful paint (en-US)
- First paint (en-US)
- HTTP
- HTTP/2
- Jank (en-US)
- Latency
- Lazy load
- Long task (en-US)
- Lossless compression (en-US)
- Lossy compression (en-US)
- Main thread (en-US)
- Minification (en-US)
- Network throttling (en-US)
- Packet (en-US)
- Page load time (en-US)
- Page prediction (en-US)
- Parse (en-US)
- Perceived performance (en-US)
- Prefetch (en-US)
- Prerender (en-US)
- QUIC
- RAIL (en-US)
- Real User Monitoring (en-US)
- Resource Timing (en-US)
- Round Trip Time (RTT) (en-US)
- Server Timing (en-US)
- Speculative parsing (en-US)
- Speed index (en-US)
- SSL
- Synthetic monitoring (en-US)
- TCP handshake (en-US)
- TCP slow start (en-US)
- Time to first byte (en-US)
- Time to interactive (en-US)
- TLS
- Transmission Control Protocol (TCP)
- Tree shaking (en-US)
- Web performance (en-US)
See also
HTML
- The
<picture>
Element - The
<video>
Element - The
<source>
Element - The
<img> srcset
attribute - Preloading content with
rel="preload"
- https://w3c.github.io/preload/
CSS
- will-change
- GPU v CPU
- Measuring layout
- Font-loading best practices
JavaScript
APIs
- Performance API
- Navigation Timing API
- Media Capabilities API
- Network Information API
- PerformanceNavigationTiming
- Battery Status API
- Navigator.deviceMemory
- Intersection Observer
- Using the User Timing API
- Long Tasks API
- High Resolution Timing API (https://w3c.github.io/hr-time/)
- Resource Timing API
- Page Visibility
- Cooperative Scheduling of Background Tasks API
- Beacon API
- Resource Hints - dns-prefetch, preconnect, prefetch, and prerender
- FetchEvent.preloadResponse
- Performance Server Timing API
Headers
- Content-encoding
- HTTP/2
- gZip
- Client Hints
Tools
Additional Metrics
- Speed Index and Perceptual Speed Index
Best Practices
- Using Service Workers
- Using Web Workers
- PWA
- Caching
- Content Delivery Networks (CDN)