How can I make a screen width condition to a script tag on a shopify liquid

How can I create a condition to to a script tag (the first script tag ) The condition is: Keep the line if screen width > 760px Else: delete this script tag ?

The language is liquid (Shopify)

I know that liquid is a backend so I have no access to the screen width. I know that I could do it width JS and the script tag is on JS.

{% if product.media.size > 0 %}
  <script src="{{ 'product-modal.js' | asset_url }}" defer="defer"></script>
  <script src="{{ 'media-gallery.js' | asset_url }}" defer="defer"></script>
{% endif %}

Hi @uriWebfusion ,

Since Liquid is rendered server side I wouldn’t think you can access the client screen size so you would have to go with JS.

1 Like

I know and I mentioned it in my question. The question is how to make the first script tag disappear within JS?

@uriWebfusion can you try below code in theme.liquid file

{% if product.media.size > 0 %}

{% endif %}