0

Does anyone know if it's possible with the Shopify API to inject JavaScript code into Shopify template files like you can do using the Script Tags API with JavaScript files.

My goal is to have the app hit the server, get JavaScript code like <script type="text/javascript">console.log('App is running')</script> and inject that into every template page.

That way you wouldn't need to edit the themes template files.

I'm not looking for recommendations for books, tools, software libraries, and more. I want to know if it's possible to do this with the Shopify API.

1 Answer 1

1

The short answer is yes. You can inject your Javascript into theme templates, because they are just that. Templates. Adding code to them is not difficult. You edit them with the API.

But if you did that, you'd be mangling the theme. If someone deleted your App, that mangling would remain.

So you do not do that. You get to stick with Script Tags.

You should re-think your strategy. Stick to what works, cleanly. I am pretty sure Shopify would hammer ban you anyway, but still, at least you know now.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.