Re: [csswg-drafts] [cssom-view] {element, elements, nodes}FromPoint but without restricting to the viewport clip? (#4122)

> Interesting. Do you know what the difference is that led to the worse performance? (I'm not necessarily saying it must have been the same, just trying to understand your use-case better.)

For reference:
* [`IntersectionObserver` profile](https://perfht.ml/2ZbjKnK)
* [`elementsFromPoint` profile](https://perfht.ml/2lsua3f)

I have some ideas:
* While `IntersectionObserver` is async, the framework that calls `isVisible` is sync. Therefore I had to do the observer work as pre-processing outside of the `isVisible` method. One thing the framework does is filter out some elements that we don’t care about. In the preprocessing step with `IntersectionObserver`, I am looking at all elements rather than a subset.
* Also, this preprocessing work occurs as soon as the script is loaded, rather than being called as part of the framework. This means it gets executed almost a full second earlier. Based on the profile, this is before the page has finished loading. This means thousands of observers are being added during page load.
  * I acknowledge that one option here is to do this work during idle times. While this is an option for some applications, it is not for others.
* With the `IntersectionObserver` approach, I am caching information in the global scope (using a `Set`) in an unbounded way (e.g. for the sample page, my set has over 6000 HTML elements in it).

While it’s possible I could eventually make `IntersectionObserver` work for my use case, it doesn’t seem intended for this purpose, whereas `elementsFromPoint` seems much more closely aligned.

> Could you explain in more detail what you're doing with this information? Again, just trying to learn and understand the use-case.

Sure. I am working on an open-source framework called [Fathom](https://github.com/mozilla/fathom) that tries to extract semantic information from web pages.

-- 
GitHub Notification of comment by biancadanforth
Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/4122#issuecomment-516692928 using your GitHub account

Received on Wednesday, 31 July 2019 04:43:06 UTC