How do I remove a script from the customization section but keep it on the view page?

Solved

How do I remove a script from the customization section but keep it on the view page?

sourav-dev
Shopify Partner
3 1 1

hello I want to add script from my custom app to the view page of my website but it also show me in customization section i don't want it please help me https://prnt.sc/nT4WFyz012HS i don't want alert box here : https://prnt.sc/sDiyfLDrI8ou i only want it in website view section onlyScreenshot_2.png

Accepted Solution (1)

sourav-dev
Shopify Partner
3 1 1

This is an accepted solution.

{% if request.design_mode %}
  {% else  %}
    <script>
        alert ("home page");
    </script>
{% endif %}
I found the solution after some research you just need to ad this conditional statement to remove scripts from customization of designing part 

View solution in original post

Replies 2 (2)

sourav-dev
Shopify Partner
3 1 1

This is an accepted solution.

{% if request.design_mode %}
  {% else  %}
    <script>
        alert ("home page");
    </script>
{% endif %}
I found the solution after some research you just need to ad this conditional statement to remove scripts from customization of designing part 

chefJuanPi
Shopify Partner
23 1 9
on this scenario it's better use unless than if
 
{%- unless request.design_mode %}
  <script> alert ("home page");</script>
{%- endunless -%}