Commit fdbde7c9 authored by David Barr's avatar David Barr Committed by Enrique Alcántara

Support load timings for non-Chromium browsers

Attempt to find the performance paint entry based on the
'first-contentful-paint' name. Returns NaN to the user
if the entry cannot be found

Changelog: other
MR: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/81260
parent 24721913
...@@ -82,7 +82,9 @@ const initPerformanceBar = (el) => { ...@@ -82,7 +82,9 @@ const initPerformanceBar = (el) => {
let summary = {}; let summary = {};
if (navigationEntries.length > 0) { if (navigationEntries.length > 0) {
const backend = Math.round(navigationEntries[0].responseEnd); const backend = Math.round(navigationEntries[0].responseEnd);
const firstContentfulPaint = Math.round(paintEntries[1].startTime); const firstContentfulPaint = Math.round(
paintEntries.find((entry) => entry.name === 'first-contentful-paint')?.startTime,
);
const domContentLoaded = Math.round(navigationEntries[0].domContentLoadedEventEnd); const domContentLoaded = Math.round(navigationEntries[0].domContentLoadedEventEnd);
summary = { summary = {
......
...@@ -48,12 +48,13 @@ From left to right, the performance bar displays: ...@@ -48,12 +48,13 @@ From left to right, the performance bar displays:
- **External HTTP calls**: the time taken (in milliseconds) and the total - **External HTTP calls**: the time taken (in milliseconds) and the total
number of external calls to other systems. Click to display a modal window number of external calls to other systems. Click to display a modal window
with more details. with more details.
- **Load timings** of the page: if your browser supports load timings (Chromium - **Load timings** of the page: if your browser supports load timings, several
and Chrome) several values in milliseconds, separated by slashes. values in milliseconds, separated by slashes.
Click to display a modal window with more details. The values, from left to right: Click to display a modal window with more details. The values, from left to right:
- **Backend**: time needed for the base page to load. - **Backend**: time needed for the base page to load.
- [**First Contentful Paint**](https://web.dev/first-contentful-paint/): - [**First Contentful Paint**](https://web.dev/first-contentful-paint/):
Time until something was visible to the user. Time until something was visible to the user. Displays `NaN` if your browser does not
support this feature.
- [**DomContentLoaded**](https://developers.google.com/web/fundamentals/performance/critical-rendering-path/measure-crp) Event. - [**DomContentLoaded**](https://developers.google.com/web/fundamentals/performance/critical-rendering-path/measure-crp) Event.
- **Total number of requests** the page loaded. - **Total number of requests** the page loaded.
- **Memory**: the amount of memory consumed and objects allocated during the selected request. - **Memory**: the amount of memory consumed and objects allocated during the selected request.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment