When you’re adding Javascript to app embed blocks, you’ll need to contain the scripts in a separate .js file, which will be in the assets
directory. You can see an example of what the file structure should be here: Theme app extension configuration
and here’s a basic theme app extension example, where there are multiple .js files in the /assets directory theme-extension-getting-started/assets at main · Shopify/theme-extension-getting-started · GitHub
Then you can reference the .js file in the app extensions’ schema:
{% schema %}
{
"name": "Image Gallery",
"target": "section",
"stylesheet": "image-gallery.css",
"javascript": "image-gallery.js",
"templates": ["product", "index"],
Hope this helps!