How to implement scrolling to an element after loading?

I am trying to implement a feature that current page view will scroll to a component after everything is completely loaded. I did not find any helpful guide, like loading state/hooks, etc. Hence, I implemented my own version. I am posting this here to see if there is a more official way to implement the requirement.

My implementation is taking the hash from URL, checking the loading attributes, and scrolling to it until all loading attributes are gone.

@app.clientside_callback(
        """
        function(hash) {
            const intervalId = setInterval(() => {
                const isLoading = document.querySelector("div[data-dash-is-loading='true']");
                const scrollToEl = document.getElementById(hash.replace("#",""));
                if (!isLoading && scrollToEl) {
                    scrollToEl.scrollIntoView();
                    clearInterval(intervalId);
                }
            }, 1000);
        }
        """,
        Output('pseudo-output', 'children'),
        Input('tabs-url', 'hash'),
    )

Please let me know if I am on the right path or there is a correct way to implement this/