Closed yoavweiss closed 2 years ago
Turns out that there's already a (chromium-only, unspecified) API called document.wasDiscarded
that provides that signal.
Apologies but it looks like the API is specified in https://wicg.github.io/page-lifecycle/#dom-document-wasdiscarded
And from the Chromium issue, it seems like wasDiscarded
provides a sufficient signal for now. Closing!
See https://bugs.chromium.org/p/chromium/issues/detail?id=1320480
On some platforms, the browser can discard backgrounded tabs from memory, resulting in them being reloaded if & when the user goes back to them. Currently there's no way to distinguish those reloads from user-initiated ones. It'd be good if there was, to enable developers understand which portion of their pages get discarded in the background, and optimize for that (e.g. by improving their caching, etc).