Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support browsers without IntersectionObserver #165

Open
jorrit opened this issue Jun 19, 2023 · 5 comments
Open

Support browsers without IntersectionObserver #165

jorrit opened this issue Jun 19, 2023 · 5 comments

Comments

@jorrit
Copy link

jorrit commented Jun 19, 2023

I sometimes get error reports from old browsers that lack IntersectionObserver. I don't want to ship a polyfill for the small group of users that use these old browsers, I prefer to just show the lazy-loaded content instead.

Would you accept a PR or make the change yourself that makes lazy loaded content visible when IntersectionObserver is not available?

@loktar00
Copy link
Owner

You mean it just completely ignores the aspect of lazy loading and just displays the image fully?

Kind of on the fence... we're talking about 5% of users worldwide at most and for IE11 I'm assuming which went end of life almost exactly a year ago now.

https://caniuse.com/intersectionobserver

It really depends honestly how much it might change the component code since right now it's pretty slim overall.

@jorrit
Copy link
Author

jorrit commented Jun 21, 2023

The error was generated by an obsolete iPad device.
My idea was to add this to the top:
const intersectionNotSupported = typeof window !== 'undefined' && !('IntersectionObserver' in window);

set state.visible to true in the constructor if intersectionNotSupported is true.
Return early in componentDidMount() if componentDidMount is true.

@jorrit
Copy link
Author

jorrit commented Jul 10, 2023

I just received an error report that IntersectionObserver wasn't available even on Safari 15. It seems it's marked as an 'experimental ' feature that could be disabled by the user.

@loktar00
Copy link
Owner

Oh Safari...

Honestly I really think a polyfill would be appropriate, safari 15 is dropping out pretty fast vs 16. Just feels like a step backwards. From my former days my rule was 5% or less and I'd drop support this was for IE6-11 Safari 15 seems to be very much below that threshold fortunately.

@loktar00
Copy link
Owner

#166 is probably related to this. If you do a PR I'll happy accept since they're using 16 and it's having an issue as well. At the end of the day it doesn't "hurt" just adds a bit more code but that's better than the alternative which isn't showing any content for a user.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants