[Beginner] Basic Twitch website integration

So if i wanted to check every 30 seconds or so, i would just make what you wrote into a function that is getting called on a timer right?
Or just make it a function and call it whenever the page is loaded?