It depends what code you run in it and what API calls are done then, you seem to do something custom. You have the privacy doc here: https://shopify.dev/docs/api/customer-privacy.
Otherwise, just place your code right after the {{ content_for_header }} tag in theme.liquid file, that’s where Shopify instantiates most if not all its scripts, much better than doing a setInterval in my opinion.