I'm working on an app where we want to add some html to the merchant's store if they enable a setting in my app. Specifically, there are three settings to turn on that automatically add our html on their home page, product page, and cart. To ensure that the html shows up immediately on page load, I'm conditionally rendering a snippet in the liquid template of their theme. I followed this blog post for how conditionally render a snippet in liquid: https://www.shopify.com.sg/partners/blog/add-code-from-your-app. However, to identify where to add our snippets, it seems I have to understand the structure of every theme to determine which asset and where in that asset.liquid file to place our html. Are there any best practices here? Or do I just have to have a large if/else if block for each theme to place the html differently for each one? Are there any open source libraries that make this easier? My final thought would be to create some theme component that the merchant could drag into their theme when customizing it -- is that an option?
Currently, if my app doesn't recognize the theme, I create a liquid snippet and script tag and then tell the user to code a code snippet and manually place it in their theme.