Page load is the latency performance metrics that cumulates:
You may be also interested by the web speed page (possible duplicate)
Load is not a single moment in time — it’s an experience that no one metric can fully capture. There are multiple moments during the load experience that can affect whether a user perceives it as fast or slow.
The main page state of the loading process are available in the readyState property
The user begins a page load with a navigation:
This navigation will make the browser execute an HTTP request to retrieve the HTML page.
Browser - Page loading - The HTTP response has been received.
Metrics:
HTML code is processed by the browser in the order it appears in the file. Ie the code on the page (ie HTML, CSS, Javascript, …) is processed top down
Demo: Click on the button to start loading the HTML
<script>alert('The image is not yet downloaded because this alert is blocking. Click on the Ok button to close the alert, to resume the load process and load the image');</script>
<img src="/_media/lenna.png" width="200px"/>
Explanation:
In this phase, the browser will build the DOM document from the HTML document received in the response.
Event:
Metrics:
In this phase, the browser will fetch resources present in the HTML page.
If the linked resources are:
In this phase, the browser will transform all CSS (inline and stylesheet) into a CSSOM (tree)
The page is loaded. Image may still download. The page is not yet fully rendered.
Metrics:
Event:
Browser - Rendering ( HTML Latency)
Metrics:
Event:
Your web analytics provider should provide you with them.
Example for Google Analytics
You can get the metrics via:
Example:
// All results are reported to the analyticsTracker callback
new Perfume({
analyticsTracker: options => {
const { metricName, data, eventProperties, navigatorInformation, vitalsScore, } = options;
switch (metricName) {
case 'fp':
console.log('firstPaint duration: '+data);
return;
case 'fcp':
console.log('firstContentfulPaint duration: '+data);
return;
case 'lcp':
console.log('largestContentfulPaint duration: '+data);
return;
default:
return;
}
},
});
The below table lists the parameters that have an impact on the speed of your page load.
Resources | Javascript | Css Stylsheet | Image / Video | TCP Network | Description |
---|---|---|---|---|---|
Preload | x | x | Load non-critical Javascript or CSS | ||
Async/Defer | x | Loading in parallel | |||
Lazy loading | x | Load only when the element is going into the viewport | |||
Tree shaking/ pruning | x | x | Delete code that is not relevant | ||
Minify | x | x | Compress the code | ||
Responsive Image | x | Use and advertise the best image (size and format) | |||
HTTP accept encoding | x | x | Compress the HTTP content (compress, gzip, …) | ||
Edge/Cdn server | x | x | x | x | Serve the page and resources close to the user |
HTTP cache / Bundle / Inline | x | x | x | x | Reduce the number of resource requests (Bundle or incorporate in your page) |
HTTP request for resources have a latency cost. You can see their effect in the devtool network tab.
In this case, even if the resources (css, js, img) were not modified and in the cache, the browser goes through a conditional cache validation request. And even if the server returns a 304 Not Modified status, the network round trips (and server response) add latency.
To eliminate this network requests, the solution are:
On a world scale, the location of the server has a great impact on the response time.
In a single server architecture can you guess where the server is located ?
This takes into account only the first byte of the response (network performance), it may add up to seconds when the full page is loaded.
Solution: Edge/Cdn server
Probability of bounce by page latency.
To record a page load, you would use a headless browser
The Page lifecycle API 1) formalizes two new lifecycle states: