[object Object]

← back to Designer Wallcoverings

Add collection grid responsive-cols + infinite-scroll fix push script (staged on dev theme 143947038771)

980385818273f75ab0cb89d481d284da9a137c75 · 2026-06-23 07:44:07 -0700 · steve@designerwallcoverings.com

Files touched

Diff

commit 980385818273f75ab0cb89d481d284da9a137c75
Author: steve@designerwallcoverings.com <steve@designerwallcoverings.com>
Date:   Tue Jun 23 07:44:07 2026 -0700

    Add collection grid responsive-cols + infinite-scroll fix push script (staged on dev theme 143947038771)
---
 shopify/push-grid-responsive-infinite.sh | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)

diff --git a/shopify/push-grid-responsive-infinite.sh b/shopify/push-grid-responsive-infinite.sh
index 32a5a180..2d52ae3b 100644
--- a/shopify/push-grid-responsive-infinite.sh
+++ b/shopify/push-grid-responsive-infinite.sh
@@ -179,16 +179,23 @@ if "DW: Grid Density Slider (3-12 columns, mobile-first)" in tl:
     end_marker = "<!-- /DW Grid Density Slider -->"
     e = tl.index(end_marker) + len(end_marker)
     tl = tl[:s] + tl[e:]; changes.append("removed-inline-density-block")
-# (b) dedupe dw-grid-control.js include -> exactly one before </head>
+# NOTE: theme.liquid has TWO </head> tags — the first is inside the
+# {% if dw_is_blocked %} China-geoblock document (renders only for CN visitors).
+# Includes MUST go before the LAST </head> (the real document head) or they
+# never load for normal shoppers.
+def inject_before_last_head(src, line):
+    idx = src.rfind("</head>")
+    return src[:idx] + line + "\n" + src[idx:] if idx != -1 else src
+# (b) dedupe dw-grid-control.js include -> exactly one before the REAL </head>
 gc_inc = re.compile(r'[ \t]*<script src="\{\{ \'dw-grid-control\.js\' \| asset_url \}\}" defer></script>\n?')
 n_gc = len(gc_inc.findall(tl))
 if n_gc != 1:
     tl = gc_inc.sub('', tl)
-    tl = tl.replace("</head>", '<script src="{{ \'dw-grid-control.js\' | asset_url }}" defer></script>\n</head>', 1)
+    tl = inject_before_last_head(tl, '<script src="{{ \'dw-grid-control.js\' | asset_url }}" defer></script>')
     changes.append("deduped-grid-control-include(%d->1)" % n_gc)
-# (c) ensure newwall-infinite.js include (infinite scroll) before </head>
+# (c) ensure newwall-infinite.js include (infinite scroll) before the REAL </head>
 if "newwall-infinite.js" not in tl:
-    tl = tl.replace("</head>", '<script src="{{ \'newwall-infinite.js\' | asset_url }}" defer></script>\n</head>', 1)
+    tl = inject_before_last_head(tl, '<script src="{{ \'newwall-infinite.js\' | asset_url }}" defer></script>')
     changes.append("added-infinite-scroll-include")
 if changes:
     backup("layout/theme.liquid", torig); put("layout/theme.liquid", tl)

← 7827786f Fix grid density slider mobile hiding: add !important + 480p  ·  back to Designer Wallcoverings  ·  auto-save: 2026-06-23T07:50:15 (83 files) — DW-Agents/dw-age 2a4e2a61 →