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
how to detect browser support for IntersectionObserver to avoid load #296
Comments
You can try something like if (!'IntersectionObserver' in window &&
!'IntersectionObserverEntry' in window &&
!'intersectionRatio' in window.IntersectionObserverEntry.prototype) {
// load polyfill now
} |
Easy mistake to make, but because the intent is to fallback should any prerequisite not be satisfied || should be used rather than &&, i.e. if we don't have this or we don't have that...),. Alternatively, use && with positive tests and negate the entire expression (we need this and that, and if we don't have all of them...). |
@midzer tested in Safari, doesn't work unfortunately. I put a simple console.log inside the brackets and it is not triggered. @nickion using || generates the following error on line 3:
I got this to work in Safari with the following:
|
that's the error you would expect to get when using However, there's another issue which is that
|
FYI, on some versions of Chrome, Opera and Edge IntersectionObservers are partially implemented so the check |
@joselanderosmrf Or you use |
Just use the polyfill:
|
How can I check if ( ! IntersectionObserver ) in javascript to see if browser supports it?
So I only load if not supported.
The text was updated successfully, but these errors were encountered: