Discuss and resolve questions on Liquid, JavaScript, themes, sales channels, and site speed enhancements.
Hi, I detected strange behavior working with the Liquid tag {% javascript %}.
I move to other file some of the custom components created by default in the Dawn theme, but I do not change the JS code. All seemed to work well, and I deployed to production. In production, this code not works properly, and after a long time debugging it, I found that the code inside {% javascript %} always show the previous state of code, like there's a cache or something.
For instance:
1. I create a console.log("a") in my code, inside the {% javascript %} tag, and save it.
2. The web console not shows nothing.
3. I modify the console log to console.log("b") and save it.
4. The web console shows "a".
5. I remove the console.log and save it.
6. The web console shows "b".
This happens in local (with Shopify CLI) and in production.
- Dawn v.7.0.1
- Shopify CLI and GitHub integration
Hi @ivanbarcia,
You can change:
{% javascript %} => <script>
it will work fine. Refer https://shopify.dev/themes/architecture/sections/section-assets#javascript
Hope it helps!
Thanks for your reply. That is not very correct on many occasions. If we are dealing with a section that is used in different places, you may be loading the same JS several times. That's what{% javascript %} avoids and that's why I was trying to use it in this case.
Discover how to increase customer engagement on your store with articles from Shopify A...
By Jacqui Apr 23, 2025Hey Community 👋 Did you know that March 15th is National Everything You Think Is W...
By JasonH Apr 1, 2025Discover how to increase the efficiency of commerce operations with Shopify Academy's l...
By Jacqui Mar 26, 2025