let distance = 50; function go(){ var scrollHeight = document.body.clientHeight; setTimeout(()=>{ window.scrollTo(0,distance); distance+=50; console.log(distance) if(distance<scrollHeight){ go() } },100)}go()