From 668373c2736de25b1b843cccb38d5cfa4db562ed Mon Sep 17 00:00:00 2001
From: Noam Rosenthal The following terms are defined in Performance Timeline: Set document's visibility state to
visibilityState. Queue a new
+
+
+
+
PerformanceEntry
and its
+ name
,
+ entryType
,
+ startTime
, and
+ duration
attributes.VisibilityStateEntry
whose
+ visibility state is
+ visibilityState and whose timestamp is
+ the current high resolution time given document's
+ relevant global object.
VisibilityStateEntry
interfaceThe VisibilityStateEntry
interface exposes visibility changes to the document,
+ from the moment the document becomes active.
function wasHiddenBeforeFirstContentfulPaint() {
+ const fcpEntry = performance.getEntriesByName("first-contentful-paint")[0];
+ const visibilityStateEntries = performance.getEntriesByType("visibility-state");
+ return visibilityStateEntries.some(e =>
+ e.startTime < fcpEntry.startTime &&
+ e.name === "hidden");
+}
+ Since hiding a page can cause throttling of rendering and other user-agent + operations, it is common to use visibility changes as an indication that such throttling has + occurred. However, other things could also cause throttling in different browsers, such as + long periods of inactivity.
+ +[Exposed=(Window)]
+interface VisibilityStateEntry : PerformanceEntry {
+ readonly attribute DOMString name; // shadows inherited name
+ readonly attribute DOMString entryType; // shadows inherited entryType
+ readonly attribute DOMHighResTimeStamp startTime; // shadows inherited startTime
+ readonly attribute unsigned long duration; // shadows inherited duration
+};
+
+ The VisibilityStateEntry
has an associated
+ DOMHighResTimeStamp
+ timestamp.
The VisibilityStateEntry
has an associated "visible
" or
+ "hidden
" visibility state.
The name
getter steps are to return
+ this's visibility state.
The entryType
getter steps are to return
+ "visibility-state
".
The startTime
getter steps are to return
+ this's timestamp.
The duration
getter steps are to return
+ zero.
Queue a new
+ VisibilityStateEntry
whose visibility
+ state is document's visibility state and whose timestamp is zero.
Set window's relevant settings object's execution ready flag.