Check if bottom of page is visible

OSCC · JavaScript, Browser · Oct 22, 2020

Checks if the bottom of the page is visible.

  • Use Window.scrollY, Element.scrollHeight and Element.clientHeight to determine if the bottom of the page is visible.
const bottomVisible = () =>
  document.documentElement.clientHeight + window.scrollY >=
  (document.documentElement.scrollHeight ||
    document.documentElement.clientHeight);
bottomVisible(); // true

Recommended snippets