An example of infinite scroll that loads new items on both hitting the bottom and the top of the page and trims the total amount of items so that a maximum number of items in the page is capped.
On macOS Firefox, when flicking the touchpad to give the scroll a significant momentum, the scrollbar reaches the bottom of the page and gets stopped abruptly which does not preserve its momentum. Instead, we could try detecting the speed of scrolling soon and adjust the mounted content accordingly so that it grows fast enough to drain the momentum of the scroll without reaching the end of the page before more content is loaded.
Host using GitHub Pages to get a URL with the correct MIME.