Apps are all loaded in the header via a single script call, then the remaining assets are loaded below. This process takes place in the liquid tag content_for_header
.
-
Open theme.liquid and locate the line which reads
{{ content_for_header }}
. -
Now you can paste the following block of code to disable all apps on a new line before
{{ content_for_header }}
.
{% comment %} Leave url_to_remove as 0 to remove all apps, or set to a number to remove a specific app. {% endcomment %}
{% assign url_to_remove = 0 %}
{% assign lines = content_for_header | newline_to_br | split: '<br />' %}
{% for line in lines %}
{% if line contains 'var urls' %}
{% if url_to_remove == 0 %}
{% comment %}Remove all apps{% endcomment %}
{% capture new_line %}
{% endcapture %}
{% assign empty_array = new_line | append: "var urls = [];" %}
{% assign content_for_header = content_for_header | replace: line, empty_array %}
<!-- Removed all apps. -->
{% else %}
{% assign url_string = line | remove: "var urls = [" | remove: "];" | strip %}
{% assign url_array = url_string | split: ',' | uniq %}
{% comment %}Just remove app at index 'url_to_remove' {% endcomment %}
{% for url in url_array %}
{% if forloop.index == url_to_remove %}
{% assign content_for_header = content_for_header | replace: url, '""' %}
<script>
console.log(
'%c Removed app no. {{ url_to_remove }} of {{ url_array.size }}: {{ url }}',
'color: #87C378'
);
</script>
{% endif %}
{% endfor %}
{% endif %}
{% endif %}
{% endfor %}
- Save theme.liquid. The above code will remove the assets of all apps enabled on the account by removing them from
{{ content_for_header }}
, so will disable every app which is loaded through there.
If we want to discover which of the 17 apps a store has installed is breaking everything we can disable apps one by one to troubleshoot.
-
Use the same block of code mentioned above, but don't save theme.liquid yet.
-
Now change the value of the liquid variable
url_to_remove
to a number to disable that specific app (e.g. changing it to 3 will disable the 3rd app enabled by {{ content_for_header }}, leaving the value as 0 will disable all apps). Now you can start running through each app to troubleshoot that issue. -
Visit the storefront in Google Chrome when you have an app disabled and use the inspect tool to search in the storefront's code for the following text:
Removed app no.
. You can repeat this step, disabling each app on the store 1 by 1 until you find the one causing the issue.
This only works on disabling Free apps?