Add assets to theme app extension dynamically for theme 2.0 from Shopify app

My app got rejected with a message “Your app is currently using ScriptTag API. Update your app to theme app extensions to ensure compatibility with Online Store 2.0 themes.”

When the app is installed an asset and the script tag are added to the store.

The asset js file is built dynamically using some data from third-party applications(This application has an authorization API key which we have stored in the shop private meta field).

eg of the js file.

var someId = '${Id}';
(function () {
var s = document.createElement('script');
s.async = true;
s.src='some src';
var parent_node = document.head || document.body;
parent_node.appendChild(s);
})();

How can we add asset files dynamically to theme app extensions from Shopify App or if we can add content dynamically from the app to the theme app extension asset folder?

Hello @arfath77 ,

I’m facing the same your issue. Did you have any solution? Please help me

Best Regards

Hello @AndyHung ,

The first thing is to check whether the theme belongs to theme 2.0
https://shopify.dev/apps/online-store/verify-support

Then in the theme-app-extension > assets folder I created my script file with all the static JavaScript code and then I exposed the dynamic field to storefront.

1 Like

Hello @arfath77 ,

Thank you so much for your help. I will try it