Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Page Visibility API is used in tools like react query, where it will show the page with the existing cached data, but refetch in the background upon a page visibility event. It feels natural for some apps to have this update-on-focus behavior, and it's nicer than polling with set interval.

Intl API is great, but I feel it's somewhat hamstrung because Node doesn't have matching APIs.



Page Visibility is also often abused to force you to watch videos/ads in their entirely without switching to another page. If any one here suffers from something like this, be sure to check out extensions like "Always active window" on Firefox, which would spoof it to make it look like you are on the page the entire time.


Another option: Open devtools and run

> document.querySelector('video').playbackRate = 10

or

> document.querySelectorAll('video').forEach(v => v.playbackRate = 10)


Oh, fascinating. I've never encountered that before. Thanks for sharing that use case and extension.


> Intl API is great, but I feel it's somewhat hamstrung because Node doesn't have matching APIs.

Are you sure? It seems to be very well supported in Node.js: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe...


Years ago I used this on my web application to work around a bug/leak. There was an auto update feature that ran on a regular basis. I made a mistake somewhere when replacing page elements that slowly increased memory usage. While developing I would close everything at the end of the day but my users would leave the page up for days. Eventually the small leak would crash the tab.

I "fixed" it by shutting off auto update on page blur then immediately doing an update on focus.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: