ampproject / ampproject/amphtml

Deduplicate uses of intersection-observer measurements

Open
#33,678 1 comment 1 reaction 1 assignee Claimed by @samouri View on GitHub
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

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.