const footer = window.document.getElementById('#footer');

const callback = function (entries, observer) {
  // Function executed when the intersection status changes
};

// The observer object. It can be applied to multiple DOM elements
const observer = new IntersectionObserver(callback, {
  rootMargin: "-10px 0px -10px 0px",
});

if (footer !== null) {
  // Listen changes on a single element
  observer.observe(footer);

  // Stop listening a single element
  observer.unobserve(footer);

  // Stop listening all elements.
  observer.disconnect();
}