How to run self updating trending posts list

I have this trending posts function working on my site: https://www.wix.com/velo/example/trending-posts

It calls a loadtrendingposts function from w.onready currently.

$w . onReady ( function () {
return loadTrendingPosts ()
});

Is there a way I can change this to run before the site is fully loaded, and also to update it periodically while the user is on the site? For example have this function run every 30 seconds etc?

Thanks.

you can generate an interval, to start the function you want every x-time…