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:
In this section
- Budgets de performance
Un budget de performance est une limite pour éviter les régressions. Il peut s'appliquer à un fichier, un type de fichier, tous les fichiers chargés sur une page, une métrique spécifique (par exemple, Time to Interactive), une métrique personnalisée (par exemple, Time to Hero Element), ou un seuil sur une période de temps.
- Le chargement différé
Le chargement différé (lazy loading en anglais) est une stratégie d'identification des ressources non bloquantes (non critiques) afin de ne les charger qu'au moment où elles sont utiles. C'est une façon de raccourcir le chemin critique de rendu (en-US), ce qui se traduit par une réduction du temps de chargement de la page.
Les utilisateurs veulent des expériences Web avec un contenu rapide à charger et une interaction fluide. Par conséquent, un développeur doit s'efforcer d'atteindre ces deux objectifs.
- Temps de chargement : à partir de quel moment un site est-il « lent » ?
Il n'y a pas de règle stricte définissant ce qui constitue un site trop long à charger, mais il y a des bonnes pratiques spécifiques pour définir un bon temps de chargement du contenu (1 seconde), de fonctionnement au ralenti (50 millisecondes), d'animation (16,7 secondes) ou encore de réponse à la saisie d'un visiteur (50 à 200 millisecondes).
The MDN Web Performance Learning Area contains modern, up-to-date tutorials covering Performance essentials:
- What is web performance (en-US)
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.
- Web Performance Basics (en-US)
- How do users perceive performance? (en-US)
More important than how fast your website is in milliseconds, is how fast do your users perceive your site to be. Page load time, idling, responsiveness to user interaction, and the smoothness of scrolling and other animations impact these perceptions. 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 themselves.
- Multimedia: Images and Video
Frequently, media optimization is the lowest hanging fruit of web performance. 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 images, 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 (en-US)
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.
Using Performance APIs
- Performance API
This guide describes how to use the
Performanceinterfaces that are defined in the High-Resolution Time standard.
- Resource Timing API (en-US)
Resource loading and timing (en-US) 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
Performanceinterface 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 (en-US)
Create application specific timestamps using the user timing API (en-US)'s "mark" and "measure" entry types - that are part of the browser's performance timeline.
- Frame Timing API
PerformanceFrameTiminginterface provides frame timing data about the browser's event loop.
- Beacon API (en-US)
The Beacon (en-US) interface schedules an asynchronous and non-blocking request to a web server.
- Intersection Observer API (en-US)
Learn to time element visibility with the Intersection Observer API and be asynchronously notified when elements of interest becomes visible.
- Developer Tools Performance Features
This section provides information on how to use and understand the performance features in your developer tools, including Waterfall, Call Tree, and Flame Charts.
- Understanding Latency (en-US)
Latency is the amount of time it takes between the browser making a request for a resource, and the browser receiving back the first byte of the resource requested. This article explains what latency is, how it impacts performance, how to measure latency, and how to reduce it.
- Brotli compression
- Client hints
- Code splitting
- Domain sharding
- Effective connection type
- First contentful paint
- First CPU idle
- First input delay (en-US)
- First interactive (en-US)
- First meaningful paint
- First paint
- Lazy load
- Long task (en-US)
- Lossless compression
- Lossy compression
- Main thread
- Network throttling
- Page load time (en-US)
- Page prediction (en-US)
- Perceived performance (en-US)
- Prefetch (en-US)
- Prerender (en-US)
- Real User Monitoring
- Resource Timing (en-US)
- Round Trip Time (RTT) (en-US)
- Server Timing (en-US)
- Speculative parsing
- Speed index
- Synthetic monitoring (en-US)
- TCP handshake
- TCP slow start
- Time to first byte (en-US)
- Time to interactive
- Transmission Control Protocol (TCP)
- Tree shaking
- Web performance
Documents yet to be written
- 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 also looks at mobile-specific performance considerations.
- Web font performance
Bandwidth is the amount of data measured in Megabits(Mb) or Kilobits(Kb) that one can send per second. This article explains the role of bandwidth in media-rich internet applications, how you can measure it, and how you can optimize applications to make the best use of available bandwidth.
- The role of TLS in performance
TLS—or HTTPS as we tend to call it—is crucial in creating secure and safe user experiences. While hardware has reduced the negative impacts TLS has had on server performance, it still represents a substantial slice of the time we spend waiting for browsers to connect to servers. This article explains the TLS handshake process, and offers some tips for reducing this time, such as OCSP stapling, HSTS preload headers, and the potential role of resource hints in masking TLS latency for third parties.
- Reading performance charts
Developer tools provide information on performance, memory, and network requests. Knowing how to read waterfall charts, call trees, traces, flame charts , and allocations in your browser developer tools will help you understand waterfall and flame charts in other performance tools.
- Alternative media formats
When it comes to images and videos, there are more formats than you're likely aware of. Some of these formats can take your highly optimized media-rich pages even further by offering additional reductions in file size. In this guide we'll discuss some alternative media formats, how to use them responsibly so that non-supporting browsers don't get left out in the cold, and some advanced guidance on transcoding your existing assets to them.
- Lazy loading
It isn't always necessary to load all of a web applications assets on initial page load. Lazy Loading is deferring the loading of assets on a page, such as scripts, images, etc., on a page to a later point in time i.e when those assets are actually needed.
- Controlling resource delivery with resource hints
Browsers often know better than we do when it comes to resource prioritization and delivery however they're far from clairyovant. Native browser features enable us to hint to the browser when it should connect to another server, or preload a resource before the browser knows it ever needs it. When used judiciously, this can make fast experience seem even faster. In this article, we cover native browser features like rel=preconnect, rel=dns-prefetch, rel=prefetch, and rel=preload, and how to use them to your advantage.
- Performance Budgets
Marketing, design, and sales needs, and developer experience, often ad bloat, third-party scripts, and other features that can slow down web performance. To help set priorities, it is helpful to set a performance budget: a set of restrictions to not exceed during the development phase. In this article, we'll discuss creating and sticking to a performance budget.
- Web performance checklist
A performance checklist of features to consider when developing applications with links to tutorials on how to implement each feature, include service workers, diagnosing performance problems, font loading best practices, client hints, creating performant animations, etc.
- Mobile performance checklist
A concise checklist of performance considerations impacting mobile network users on hand-held, battery operated devices.
- Performance fundamentals
A wide overview of Web application performance, what it is, how the browser helps to improve it, and what tools and processes you can use to test and further improve it.
- Optimizing startup performance
Tips and suggestions to help you improve start-up performance, both when writing a new app and when porting an app from another platform to the Web.
- Profiling with the built-in profiler
Learn how to profile app performance with Firefox's built-in profiler.
- Preloading content with
- GPU v CPU
- Measuring layout
- Font-loading best practices
- Performance API
- Navigation Timing API (en-US)
- Media Capabilities API (en-US)
- Network Information API
- Battery Status API
- Navigator.deviceMemory (en-US)
- Intersection Observer
- Using the User Timing AP (en-US)I
- Long Tasks API (en-US)
- High Resolution Timing API (https://w3c.github.io/hr-time/)
- Resource Timing API (en-US)
- Page Visibility
- Cooperative Scheduling of Background Tasks API (en-US)
- Beacon API (en-US)
- Resource Hints - dns-prefetch (en-US), preconnect, prefetch, and prerender
- Fetchevent.navigationPreload (en-US)
- Performance Server Timing API
- Client Hints
- Performance in Firefox Developer Tools
- Flame charts
- The Network panel
- Waterfall charts
- Speed Index and Perceptual Speed Index
- Using Service Workers
- Using Web Workers
- PWA (en-US)
- Content Delivery Networks (CDN)