Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
72 changes: 59 additions & 13 deletions App Optimization/app-optimization.liquid
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,21 @@

for block in section.blocks
assign url = block.settings.url | replace: '/', '\/'

if content_for_header contains url or block.settings.not_an_app
if block.settings[block_key] == true
assign arr_block = block | concat: arr_block
endif

if block.settings[scroll_key] == true
assign arr_scroll = block | concat: arr_scroll
endif

if block.settings[interaction_key] == true
assign arr_interaction = block | concat: arr_interaction
endif
endif

if block.settings[block_key] == true and content_for_header contains url
assign arr_block = block | concat: arr_block
endif

if block.settings[scroll_key] == true and content_for_header contains url
assign arr_scroll = block | concat: arr_scroll
endif

if block.settings[interaction_key] == true and content_for_header contains url
assign arr_interaction = block | concat: arr_interaction
endif
endfor

assign settings_data = arr_block | concat: arr_scroll | concat: arr_interaction | uniq | map: 'settings'
Expand Down Expand Up @@ -200,7 +203,8 @@
{%- comment -%}
The code below will be loaded only in the Theme Editor
{%- endcomment-%}
{%- assign urls = content_for_header | split: 'var urls =' | last | split: 'for (var i = 0' | first | remove: ';' | split: ',' -%}
{%- assign urls = content_for_header | split: 'var urls =' | last | split: 'for (var i = 0' | first | remove: ';' -%}
{%- assign urls_array = urls | split: ',' -%}

<template id="sd-app-list-template">
<style>
Expand Down Expand Up @@ -373,7 +377,7 @@
</tr>
</thead>
<tbody>
{%- for url in urls -%}
{%- for url in urls_array -%}
{%- liquid
assign name = 'App name'
assign load = 'Default'
Expand Down Expand Up @@ -411,6 +415,42 @@
<td class="text-right"><p data-badge="{{ load }}">{{ load }}</p></td>
</tr>
{%- endfor -%}
{%- capture custom_scripts -%}
{%- assign urls = urls | replace: '\/', '/' -%}
{%- for block in section.blocks -%}
{%- unless urls contains block.settings.url -%}
{%- liquid
assign load='Default'
if block.settings.not_an_app
if block.settings[block_key] == true
assign load = 'Block'
elsif block.settings[scroll_key] == true
assign load = 'Scroll'
elsif block.settings[interaction_key] == true
assign load = 'Interaction'
endif
endif
-%}
<tr>
<td><p>{{ block.settings.title }}</p></td>
<td>
<p class="flex whitespace-no-wrap">
{{ block.settings.url }}
</p>
</td>
<td class="text-right"><p data-badge="{{ load }}">{{ load }}</p></td>
</tr>
{%- endunless -%}
{%- endfor -%}
{%- endcapture -%}
{%- unless custom_scripts == blank %}
<tr>
<td>
<h4 class="mb-4">Non-App scripts</h4>
</td>
</tr>
{{ custom_scripts }}
{% endunless %}
</tbody>
</table>
</div>
Expand Down Expand Up @@ -517,6 +557,12 @@
"placeholder": "e.g. shopifycdn.com/assets/v4/spr.js",
"info": "Use partial URL, e.g: shopifycdn.com/assets/v4/spr.js"
},
{
"type": "checkbox",
"id": "not_an_app",
"label": "This is not a main App script",
"info": "Allows control of scripts which are not direrctly loaded via Scrip Tags"
},
{
"type": "header",
"content": "Block script from loading"
Expand Down