Prachi works as a full-stack developer, specialized in e-commerce and mobile app development.
To boost the performance of a website, it is important to learn about web performance measuring techniques. This starts by understanding the vocabulary and metrics, first.
Measuring techniques can give us reliable information about our present status. Through this, we can set goals and perform the measurement again to find out the improvement in performance.
Here, we are going to understand the analytics methods required to improve web performance. For this, we’ll also learn optimization vocabulary and metrics relevant to web performance.
We must keep in mind that without measuring, we can’t improve. So, measuring plays an essential role in performance improvement.
To simplify it, we’ll use loading and responsiveness as two different categories to measure the performance.
1. Performance Measurement: Loading
Traditionally, web performance is computed using the following two methods:
- window’s onload event
- response time taken by the server
These methods are no longer quite important because, now, the performance is measured through the user’s perception.
Loading is a performance measurement that determines how speedily a website or web content appears on the user’s browser. This includes fetching of the resources from the server and its rendering on the screen.
By user’s perception, we mean how fast the user views the site and its content. It is, indeed, more important than the loading time and can be specified by the moment the user perceives the important information on the screen.
To understand this, we’ll start by discussing the waterfall chart. This is the most important chart for determining the performance level.
The waterfall chart is an analytical diagram that displays the way resources are downloaded and parsed by the engine in a timeline. It depicts the sequence and interdependencies of resources. The modern version of the waterfall chart also points out the significant events occurred during the loading process.
Note: The waterfall chart is quite similar to the Gantt diagram. The Gantt diagram is used for project management. It shows the cascade effect on several tasks.
The chart also helps us identify the performance quality of our website, it can be either good or bad. We only need to see the number of rows and the number of resources that block the parallel downloads.
Figure 1 shows the waterfall chart of a website’s loading process.
The chart shows one row for each downloaded resource.
The X-axis represents the time that increases towards the right.
The Y-axis represents the resources that are displayed sequentially the way they are organized by the web engine.
The lines in different colors represent different stages in the performance measurement.
Waterfall charts are illustrated in two different ways. This depends on the user’s visit:
- Empty cache: When the user visits the site for the first time and there’s no cached data available.
- Cached: When the user visits the site for the second time and has all the possible files cached in the user’s local storage.
If everything’s set correctly, Figure 2 perfectly depicts the difference between the empty cache and cached waterfall charts.
Figure 2 shows the Empty cache and Cached version of the waterfall chart in order. The difference is clearly noticeable if the site is performing well. The chart is produced using webpagetest.org
The below figure shows each row with a horizontal bar. The bar depicts the resource lifecycle in the timeline. Performance tools help you divide these bars in different colors to illustrate the different phases of the resource lifecycle.
Figure 3 shows each row with a horizontal bar. The bar depicts the resource lifecycle in the timeline. Performance tools help you divide these bars in different colours to illustrate the different phases of the resource lifecycle.
Color bars depict every phase of the request processing. The larger the bar, the longer will be the time. There’s a fixed order and the phases are noted as follows:
- DNS lookup: It is the time taken by the web engine for converting the domain host to an IP address using the DNS system. Since you’ll have several resources obtained from the same domain, the DNS lookup will be calculated only once as the web engine cache the result.
- Initial connection stage: It is the stage of the TCP handshake. It is required for every high-level protocol such as HTTP to use TCP. There are cases when this stage is not possible for every processed resource. If HTTPS is used, then the stage also includes the time of SSL handshake.
- Time to First Byte (TTFB): It is the time taken by the server to send back the response to the client. When the client, whether a browser or an app, sends a request, the server reacts by sending a response. The total processing time is shown in green. In case, the server is busy or there’s a requirement of fetching the data from several databases or third-party resources, the processing time increases and you can see a bigger green section in your chart.
- Final stage: The final stage includes the time taken to download the bytes of all the resources. It is represented by a blue bar on the screen. Its area depends on the present connection and bandwidth between the client and the server.
Note: Almost each of the performance tools has used the same colors for similar resources. But there are some tools that make use of different colors, so be attentive while conducting the analysis. The same order is followed i.e. the first is DNS lookup and the last is content download.
There’s one more stage involved here, which is not shown explicitly, but you can identify it easily. This is content parsing and execution.
Additionally, there are blocking and non-blocking resources. While blocking resources restrict the downloading or parsing of other resources, non-blocking ones don’t interfere in the downloading or parsing process.
Figure 4 clearly shows the gap between the tail of the blocking resource and the head of the next resource. It gives an example of blocking resources that hinder the processing of other resources. In this scenario, the waterfall chart displays the rendering time in the form of a gap.
Yellow and red background colors
Yellow and red colors mean that the resources were not downloaded properly. In this case, the received HTTP code is not 200 (OK).
A yellow color means the resource is moved to another URL. In this case, the HTTP code is either 301 (moved permanently) or 302 (moved temporarily).
A red color means a blocking error has occurred. In this case, the HTTP code is either 404 (not found) or 500 (server error).