ampproject / ampproject/amphtml
Deduplicate uses of intersection-observer measurements
Open
Stale
Type: Bug
WG: performance
- Dominant language
- JavaScript
- Stars
- 14.9k
- Forks
- 4.1k
- PR merge metrics
- No merged PRs in 30d
Description
See [src/utils/intersection.js](https://github.com/ampproject/amphtml/blob/master/src/utils/intersection.js) and [src/utils/intersection-no-root.js](https://github.com/ampproject/amphtml/blob/master/src/utils/intersection-no-root.js). Their slightly duplicated and exist only for performance. The `IntersectionObserver{root:document}` is not fully supported on Safari yet, which forces the polyfill. The polyfill is significantly slower than the native implementation. So when the `rootBounds` is unnecessary, we can use a simple `IntersectionObserver{root:null}` with a wider native support.
/cc @ampproject/wg-performance
Contributor guide
Assessment
This issue has not been assessed yet.