This is Kenji Baheux from the web platform team in Chrome.
We've been working on a new API called IntersectionObserver for viewability use cases.
It's available in Chrome 51.
Essentially, IntersectionObservers let you know when an observed element enters or exits the browser’s viewport or any other area of interest.
Why IntersectionObserver should the preferred approach
The current approach of polling every 100ms, with or without smart mitigations such as listening for scroll events, is inherently inefficient and a performance footgun (e.g inopportune calls to functions that lead to layout trashing).
To make this more concrete, here is a recent example.
A couple of days ago, this tweet by John Gruber caught my attention:
"One Chrome tab open to Forbes: CPU shot up to 77% and iMac’s fan came on for first time in weeks. Shocker that content blockers are popular." - John Gruber.
I did a deep dive and it turns out that this is largely explained by multiple third parties using the inefficient approach to viewable impression (as well as third parties that seem to be performing unwarranted work for ads that are offscreen). I'll reach out to individual stakeholders to get to the bottom of it.
Hi,
This is Kenji Baheux from the web platform team in Chrome. We've been working on a new API called IntersectionObserver for viewability use cases. It's available in Chrome 51.
Essentially, IntersectionObservers let you know when an observed element enters or exits the browser’s viewport or any other area of interest.
Resources
Why IntersectionObserver should the preferred approach The current approach of polling every 100ms, with or without smart mitigations such as listening for scroll events, is inherently inefficient and a performance footgun (e.g inopportune calls to functions that lead to layout trashing).
To make this more concrete, here is a recent example. A couple of days ago, this tweet by John Gruber caught my attention: "One Chrome tab open to Forbes: CPU shot up to 77% and iMac’s fan came on for first time in weeks. Shocker that content blockers are popular." - John Gruber.
I did a deep dive and it turns out that this is largely explained by multiple third parties using the inefficient approach to viewable impression (as well as third parties that seem to be performing unwarranted work for ads that are offscreen). I'll reach out to individual stakeholders to get to the bottom of it.