PAGEVIS

Page Visibility

[10] Page Visibility は、Webページが表示されているかどうかに関する機能です。

[20] 略称「pagevis」で呼ばれることがあります。

仕様書

API

[11] Page Visibility では次の API が定義されています。

歴史

[15] 最初この仕様は Chrome 開発チームから WHATWG に提案されました (>>12) が、 Ian Hickson は時期尚早であり、また HTML より CSSOM に属するべきであるとしました (>>13)。 この間に新たに設立された W3CWeb Performance Working Group に持ち込まれ、 憲章 (>>14) に組み込まれて作業が進められることとなりました。

[16] その後順調に進み (>>14 の予定より1年遅れていますが、 W3C でこの程度の遅れで済むのは例外的な方ですw)、 2013年2月に W3C 勧告となっています。 >>5 によれば既に主要なすべての Webブラウザーにほぼ実装されています。

[17] 仕様策定も実装もこんなに順調に進むのは極めて例外的です・・・。

[18] なぜか一部の用語は HTML で規定されているものを使っているとみられますがリンクになっていません。 そのため定義が若干曖昧になっています。

[26] >>25 で第2版が出版されていますが、差分は typo の修正だけです。

テスト・ケース

[19] Using the Page Visibility API - Web developer guide | MDN ( ( 版)) <https://developer.mozilla.org/en-US/docs/Web/Guide/User_experience/Using_the_Page_Visibility_API>

[21] webperf: Summary ( ( 版)) <https://dvcs.w3.org/hg/webperf/>

[22] webperf: File revisions ( ( 版)) <https://dvcs.w3.org/hg/webperf/log/3bc3063dc9c3/specs/PageVisibility/Overview.html>

[23] webperf: File revisions ( ( 版)) <https://dvcs.w3.org/hg/webperf/log/tip/specs/PageVisibility2/Overview.html>

[24] Page Visibility 2 ( ( 版)) <https://dvcs.w3.org/hg/webperf/raw-file/tip/specs/PageVisibility2/Overview.html>

[27] Page Visibility ( ( 版)) <https://w3c.github.io/web-performance/specs/PageVisibility/Overview.html>

[28] Re: making page visibility a property of document instead of top level browsing context (Michael van Ouwerkerk 著, 版) <https://lists.w3.org/Archives/Public/public-web-perf/2014Jan/0047.html>

These APIs

are disabled when the page is not visible: Geolocation, Vibration, Device

Motion. The goal is to save battery and CPU.

[29] Safari 7.0 ( 版) <https://developer.apple.com/library/safari/releasenotes/General/WhatsNewInSafari/Articles/Safari_7_0.html#//apple_ref/doc/uid/TP40014305-CH5-SW21>

A tab is eligible for napping when it meets any of the following conditions:

The tab is in the background.

The browser window is minimized.

The browser window is in a desktop space not currently displayed.

The browser window is occluded (covered) by another window or other object on the screen.

The browser window is idle (has not been updated recently).

The screen saver is on.

Napping is inhibited when a tab is engaged in useful nonvisual tasks such as playing audio or dynamically loading content.

[30] Safari 7.0 ( 版) <https://developer.apple.com/library/safari/releasenotes/General/WhatsNewInSafari/Articles/Safari_7_0.html#//apple_ref/doc/uid/TP40014305-CH5-SW22>

A pair of new properties on the document object allow a page to determine when it is not visible to the user, so that it can avoid unnecessary processing and minimize power consumption:

document.hidden: A Boolean flag telling whether the document is currently hidden.

document.visibilityState: A string denoting the document’s current visibility state. Possible values are:

"hidden": The document is currently hidden.

"visible": The document is currently visible.

"prerender": The document’s contents are currently being preloaded but not yet rendered. This occurs, for instance, when the user begins typing a URL into the browser’s location field: the browser attempts to predict the most likely completion of the partial URL as it is typed and begins preloading the predicted page so that it will be ready for immediate rendering when the Return key is pressed.

A new event type, visibilitychange, notifies the application when the page’s visibility state has changed. The application can install an event listener that tests the values of the properties above and responds accordingly.

[32] Called PV L2 ( (plehegar著, )) <https://github.com/w3c/page-visibility/commit/00a00c3e17068e27d3d14d63019eed26770e2136>

[33] Page Visibility 2 () <https://www.w3.org/TR/2016/WD-page-visibility-2-20160623/>

[34] ブラウザがバックグラウンド回ったことを検知する - Qiita ( ()) <https://qiita.com/d2cs-kimura/items/b51ef73528fa66a35a9d>

[35] Page Visibility Level 2 () <https://www.w3.org/TR/2016/WD-page-visibility-2-20161026/>

[36] Wide review for Page Visibility 2 (Philippe Le Hégaret著, ) <https://lists.w3.org/Archives/Public/public-web-perf/2016Oct/0006.html>

[37] Page Visibility Level 2 () <https://www.w3.org/TR/2016/CR-page-visibility-2-20161122/>

[38] Call for Exclusions: Page Visibility Level 2 (Xueyuan Jia著, ) <https://lists.w3.org/Archives/Public/public-web-perf/2016Nov/0007.html>

[39] Page Visibility Level 2 () <https://www.w3.org/TR/2017/CR-page-visibility-2-20170328/>

[40] Call for Exclusions: Page Visibility Level 2 (Xueyuan Jia著, ) <https://lists.w3.org/Archives/Public/public-web-perf/2017Mar/0022.html>

[41] Align with w3c/hr-time#47 (plehegar著, ) <https://github.com/w3c/page-visibility/commit/7972ab24110a8e20abc14d431e6d5ac86534c0b0>

[42] Page Visibility Level 2 () <https://www.w3.org/TR/2017/PR-page-visibility-2-20171017/>

[43] WICG/web-lifecycle () <https://github.com/WICG/web-lifecycle>