How to inject a custom JS script tag into the Shopify theme.liquid <head> using a custom app?

Hi everyone,

I’m working on a custom Shopify app and wondering if it’s possible to dynamically inject a custom JavaScript snippet into a store’s homepage — specifically, inside the `` section of the `theme.liquid` file.

Here’s my use case:

I want to add a UI in my app with:

* An **input box** to paste a custom JS `

```

Is there a recommended Shopify API endpoint or method (like using the [Admin API - Assets]( Asset )) to programmatically modify the theme.liquid file safely from an app?

Also, are there any best practices or restrictions when injecting custom scripts like this ?

Any guidance or code examples would be greatly appreciated! :folded_hands:

I would suggest looking at theme app extensions.