Scroll down webpage on load

Very simple, looking to automatically slowly scroll down my retool page on load.

I've got this JS code that works on other websites:

var distanceToScroll = document.body.scrollHeight - window.innerHeight;
var speed = 2; 

var scrollInterval = setInterval(function() {
    window.scrollBy(0, speed);
    
    if (window.pageYOffset >= distanceToScroll) {
        clearInterval(scrollInterval);
    }
}, 16);

But I can't get my head around how exactly Retool works with components/global JS. I've tried making a query or using it as preloaded JS but I can't get it working. Tried calling it in different ways, going through the documentation etc.

I've got some imageGrids on my page, including imageGrid8 at the bottom of the page that could be used if a component needs to be referenced.

I'm very new to using retool/front-end in general so any help is greatly appreciated.

Cheers!

Welcome to the forum!
Have you tried adding this into the App settings under the JS tab?

Hey Billy! Did Scott's solution (thank you always, Scott :pray: ) help you move forward or do you still have any questions we can help answer? :slight_smile: