Loading custom javascript-file

Short description of issue

Unable to load javascript-file

Link to Shopify Store

green-nutrition.dk

Reproduction steps

File doesn’t load when opening website

Additional info

I have uploaded js-include.js to assets - which should launch a pop-up when the website is loaded. But it doesn’t load.

Here is the code:
{%- if settings.predictive_search_enabled -%}

{%- endif -%}

{%- if settings.cart_type == 'drawer' -%}
  <script src="{{ 'cart-drawer.js' | asset_url }}" defer="defer"></script>
{{ 'js-include.js' | asset_url | script_tag }}
{%- endif -%}

I simply added in the line {{ ‘js-include.js’ | asset_url | script_tag }}
But then I get a “contains emphazized items” error on the file, and the pop-up doesnt show

What type of topic is this

Troubleshooting

1 Like

Hey @GNH :waving_hand: - can you try adding that script tag line outside of the conditionals and let me know if this resolves the issue and lets the pop up load?


{%- if settings.predictive_search_enabled -%}
…
{%- endif -%}

{%- if settings.cart_type == ‘drawer’ -%}

<script src="{{ 'cart-drawer.js' | asset_url }}" defer="defer"></script>

{%- endif -%}

<!-- Move it here, outside the conditional -->

<script src="{{ 'js-include.js' | asset_url }}" defer="defer"></script>


If you still run into errors, if you’re able to hover over the highlighted/“emphasized” line in the theme code editor and take a screenshot of the tooltip that appears and share that, this should show us the specific warning.

Also, just to confirm - is your cart type setting set to “drawer” in your theme settings? Wondering if that may be related to the issue as well.

Let me know what you find and we’ll get this looked into.