What is the best cross-browser way to detect the scrollTop of the browser window? I prefer not to use any pre-built code libraries because this is a very simple script, and
I believe the best way to get scrollTop in modern browsers is to use
const scrollTop = document.scrollingElement.scrollTop
if this doesn't work you could also try
const scrollTop = Math.max(document.documentElement.scrollTop, document.body.scrollTop, document.scrollingElement.scrollTop)