Skip to content

Instantly share code, notes, and snippets.

@deanhume
Created August 7, 2017 15:55
Show Gist options
  • Save deanhume/948c59af68c86da9d3b3f2955747a651 to your computer and use it in GitHub Desktop.
Save deanhume/948c59af68c86da9d3b3f2955747a651 to your computer and use it in GitHub Desktop.
Intersection Observer - Browser Support
// If we don't have support for intersection observer, load the images immediately
if (!('IntersectionObserver' in window)) {
Array.from(images).forEach(image => preloadImage(image));
} else {
// It is supported, load the images
observer = new IntersectionObserver(onIntersection, config);
images.forEach(image => {
observer.observe(image);
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment