TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Quirks of the Page Visibility API

53 pointsby devadvanceover 2 years ago

6 comments

jeroenhdover 2 years ago
There are still very few addons you can install on Firefox for Android (without a dev version and a bunch of hassle), but it&#x27;s telling that one of the few addons that anyone can install disables this API: <a href="https:&#x2F;&#x2F;addons.mozilla.org&#x2F;android&#x2F;addon&#x2F;video-background-play-fix&#x2F;" rel="nofollow">https:&#x2F;&#x2F;addons.mozilla.org&#x2F;android&#x2F;addon&#x2F;video-background-pl...</a>
评论 #34639083 未加载
dmitriidover 2 years ago
IIRC this comes down to disagreements between browser vendors as to what is and what isn&#x27;t potentially harmful (for a wide definition of harmful) detection of user behavior.<p>I don&#x27;t remember the details, but expect browsers to differ on details of this API basically forever.
评论 #34635799 未加载
tppiotrowskiover 2 years ago
It might make sense to detect page visibility prior to loading a pay-per-load API like Mapbox GL JS, Apple Maps on Web, etc.<p>The scenario I imagine is:<p>1. Your map is loaded<p>2. User opens a new tab (your map is now in a background tab)<p>3. User restarts browser and existing tabs are loaded<p>4. You get charged for an API load even though the page is not visible<p>Does anyone know if this is the case?<p>Edit: also analytics. If you don&#x27;t load your GA until page is visible, I wonder what impact that has on your visitor numbers
评论 #34639450 未加载
spiffytechover 2 years ago
I tried using the page visibility API to refresh displayed data when the user returned to the page after being away for a while. It&#x27;s more efficient than needlessly polling when no one&#x27;s around to see.<p>I discovered a bunch of these edge cases and had to abandon the approach - it just wasn&#x27;t reliable. The page would fail to recognize departure + return in too many scenarios and so wouldn&#x27;t refresh.
ualloover 2 years ago
Off topic: This page is yet another example of many, many websites that display a useless horizontal scrollbar. Non-overlay scrollbars simply do not work with elements that are set to a width of 100vw. Using 100vw is almost always a mistake.<p><a href="https:&#x2F;&#x2F;duckduckgo.com&#x2F;?q=avoid+100vw" rel="nofollow">https:&#x2F;&#x2F;duckduckgo.com&#x2F;?q=avoid+100vw</a>
评论 #34647812 未加载
评论 #34647832 未加载
vezycashover 2 years ago
Feels like this API is designed for web ads
评论 #34640150 未加载