14 Jan 2025 12:54 PM
If you are analyzing user actions and want to understand and quantify which load actions are loaded in the background, this post is for you.
When a page is loading in the background or when switching between browser tabs while the page is still loading, it can lead to challenges in interpreting the Waterfall analysis, such as missing or incomplete resources, ununderstandable "visually complete" time, gaps in page resource loading. These scenarios are often highlighted in the Waterfall analysis of load actions. Modern browsers significantly limit the performance of background tabs to conserve battery life and system resources.
In the currently available RUM, you can check background activities under the Waterfall analysis findings of the load user action. However, it is not possible to quantify these activities or query them using USQL.
Fortunately, you can utilize the Document.visibilityState API to monitor background activities and create a user action property within Dynatrace.
The Document.visibilityState property returns the visibility status of a document, helping determine if a page is in the background, an invisible tab, or pre-rendered. The possible values are:
visible: The page content may be at least partially visible. This typically means the page is the foreground tab of a non-minimized window.
hidden: The page content is not visible to the user. This usually indicates that the document is in a background tab, part of a minimized window, or the OS screen lock is active.
prerender: The page content is being pre-rendered and is not visible to the user (treated as hidden for purposes of document.hidden). The document may start in this state but will never transition to it from another value. Note: This value has been removed from the standard but may still appear in certain cases.
By creating a user action property using Document.visibilityState, you can:
Monitor when a page is in the background during load actions.
Analyze the impact of background activities on page resources loading, gaps between page resources
In some cases, you may notice that the document is marked as visible, yet background activities are still observed under "Show All Findings." This typically indicates that the user switched between tabs while the page was still loading.
For further details on Document.visibilityState, refer to this documentation
14 Jan 2025 03:26 PM
Thank you so much!
14 Jan 2025 04:30 PM
Great tip, all the respect.