How to connect a script through the Сustomizer when choosing a setting

How to connect a script through the Сustomizer when choosing a setting

rosstik333
Shopify Partner
4 0 0

I have a schema checkbox and I need to make sure that if it is checked, then I load the script

{%- if section.blocks.first.settings.enable_countdown_timer -%}
  <script src="{{ 'component-countdown.js' | asset_url }}" defer="defer"></script>
{% endif %}

The problem is that if you check the checkbox, it does not load, but only if you click “Save”. Can this be fixed or is it better to load it right away?

 

Replies 0 (0)