function onScroll() { if (window.pageYOffset + window.innerHeight >= document.documentElement.scrollHeight - 50) { Console.log('Reached bottom') } } window.addEventListener("scroll", onScroll);