Theme app extensions injected inside HTML comments containing `</body>`

Short description of issue

Theme app extensions are injected inside HTML comments containing </body>, breaking app functionality

Reproduction steps

  1. Open a Shopify theme’s layout file (e.g., theme.liquid)
  2. Add an HTML comment anywhere at the bottom of the file before the </body> closing tag that contains the string , for example:
    <!-- ActiveCampaign Popup — paste it before </body> in theme.liquid -->
  3. Install/enable any app that uses theme app extensions injected before the closing body tag
  4. Load the storefront and inspect the rendered HTML
  5. Observe that the theme app extension liquid markup is injected INSIDE the HTML comment (before the </body> string within the comment), instead of before the actual </body> tag at the end of the document
  6. If the app extension depends on the liquid content it does not execute because it is commented out

Additional info

Related to another bug where theme app extensions won’t load if users don’t close the </body> tag

Script and style tags linked in schema do not seem to be affected.

What type of topic is this

Bug report

Upload screenshot(s) of issue

Thanks David, we’ll have a look.