I have a Shopify App that adds a ScriptTag
via the API right after installation. The script depends on jQuery and the Shopify jQuery AJAX library. I'd like to avoid forcing merchants to edit multiple theme files if possible.
As far as I can tell:
- These dependancies aren't guaranteed to appear on every theme or in the right order.
- There's no direct way for me to reference Shopify CDN or theme scripts from the API (since it's only for remote scripts).
- Consolidating all script tags into a
scripts.liquid
asset doesn't work since API-added *.liquid assets only have access to the settings object.
I'm reluctantly leaning towards providing a snippet separately and instructions for merchants to paste it before </head>
.
Is there a Shopify-intended pattern for using ScriptTag
that I'm missing?