Re:JPEG XL support has officially been removed from Chromium
by lifthrasiir on Sunday December 11, 2022 @01:37AM
(#33940706)
Thank you for pointing out contentvisibilityautostatechanged, I was aware of `content-visibility` but didn't know that it has an associated event. I'm less sure about CSS compatibility, hotlink.js for example used an iframe which opens a whole can of worms.
You can get around many these compatibility issues by creating a custom element that inherits from HTMLImageElement. This provides API compatibility. For CSS compatibility, the elements you would replace in a MutationObserver would be the same tag name but a different namespace for CSS compatibility.
For the CSS compatibility trick, see https://eligrey.com/demos/hotlink.js/ which replaces images with CSS-compatible (not HTMLImageElement-compatible) iframes.
> - It is very hard to check if a certain image is visible or not, and react accordingly.
You can use Element.checkVisibility()¹ and the contentvisibilityautostatechanged event²𝄒³ to do this. Browser support is currently limited to Chromium-based browsers.
1. https://drafts.csswg.org/cssom-view/#dom-element-checkvisibi...
2. https://github.com/vmpstr/web-proposals/blob/main/explainers...
3. https://caniuse.com/mdn-api_element_contentvisibilityautosta...