Assuming that pageYOffset is the current scroll and then when you scroll to the bottom of the page should be equal to offsetHeight which is available for an item or so to say the total size in and of a page or item scroleable area, but not so I have to add the size of the viewport ( window.innerHeight ) and to really get the actual size and really do not understand why this must be added.