Intersection Observer & Efficient Scroll Handling

How can Intersection Observer be used to implement efficient lazy loading of iframes?
const iframeObserver = new IntersectionObserver((entries) => {
  entries.forEach(entry => {
    if (entry.isIntersecting) {
      const iframe = entry.target;
      iframe.src = iframe.dataset.src;
      iframe.removeAttribute('data-src');
      iframeObserver.unobserve(iframe);
    }
  });
}, {
  rootMargin: '50% 0px'
});
Next Question (11/20)