I am working on a theme app extension and for some reason, the CSS and JavaScript assets for the extension do not get loaded consistently by the theme editor and by the storefront.
In some cases it works fine, then without any changes in the code, it stops working. After a few page reloads it works again.
Yes, this issue can appear during development due to caching or hot-reload inconsistencies in the theme editor.
It may not happen in production, but it’s important to test thoroughly after deployment.
Try hard refreshing (Ctrl+Shift+R) or clearing cache when it happens.
Ensure your assets are being referenced properly and not dynamically loaded or altered.
If the problem persists, consider reporting it to Shopify support, as it might be a platform-side issue.
Thank your for your response @Mustafa_Ali. I have the cache disabled in the browser during development to avoid these kind of issues and on the storefront the css and js files are not requested at all. They are not visible in the source code, nor in the network requests. That’s why I think it’s not related to cache.
There are several errors in the console, but none of them are related to the extension, or extension assets. I checked it and those errors are present in the Theme Editor of a completely new dev store as well. I made a test extension with very basic css and js and I was able to reproduce the issue with those as well.
What I noticed though, is that the issue only happens, when I’m trying to test the app extension in the live theme used by the store. When I test the extension with the host theme (url provided by the cli), everything seems to be working fine.
I guess, this must be the main source of the problem. And I hope, that this is not going to be the case in production.
I did not have this issue with app embed blocks, but with regular app blocks.
make sure “developer preview” is toggled on/off either in the cli or the apps page in the partner dashboard.
Otherwise the current live assets of the app/extension are being served, not the new development assets.
I gave that a try but the issue persist. It was on by default (I guess, that’s the right setup for development), turned it off, made some tests. Turned it on again, and the behavior was the same.
For now I’m not testing the extension with the live theme, only with the host theme. That seems to be working properly.
Something similar was happening to me. To fix it, I stopped including the files as part of the schema and included them as {{ 'newsletter-contact.css' | asset_url | stylesheet_tag }}.
@feriforgacs Sometimes it is due to the compatibility or the way of parsing on some browsers as well while editing the code contents. On my end, I will choose to open a new tag under incognito mode page or switch to another browser (like from Google to Firefox for example). This situation will disappear.
You can have a try of what I said here also, it may work, who knows?