Skip to content

Commit 3056689

Browse files
authored
update featured collection so we don't lazy load images above the fold (#3741)
1 parent 9edd123 commit 3056689

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

sections/featured-collection.liquid

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,17 @@
4747
endif
4848

4949
assign columns_mobile_int = section.settings.columns_mobile | plus: 0
50+
assign columns_desktop_int = section.settings.columns_desktop | plus: 0
5051
assign show_mobile_slider = false
5152
if section.settings.swipe_on_mobile and products_to_display > columns_mobile_int
5253
assign show_mobile_slider = true
5354
endif
5455

56+
assign max_columns_to_show = columns_mobile_int
57+
if columns_desktop_int > columns_mobile_int
58+
assign max_columns_to_show = columns_desktop_int
59+
endif
60+
5561
assign show_desktop_slider = false
5662
if section.settings.enable_desktop_slider and products_to_display > section.settings.columns_desktop
5763
assign show_desktop_slider = true
@@ -97,8 +103,12 @@
97103
{% assign skip_card_product_styles = false %}
98104

99105
{%- if section.settings.collection.products.size > 0 -%}
106+
{% assign lazy_load = false %}
100107
{% paginate section.settings.collection.products by section.settings.products_to_show %}
101108
{%- for product in section.settings.collection.products limit: section.settings.products_to_show -%}
109+
{% if lazy_load == false and forloop.index > max_columns_to_show %}
110+
{% assign lazy_load = true %}
111+
{% endif %}
102112
<li
103113
id="Slide-{{ section.id }}-{{ forloop.index }}"
104114
class="grid__item{% if show_mobile_slider or show_desktop_slider %} slider__slide{% endif %}{% if settings.animations_reveal_on_scroll %} scroll-trigger animate--slide-in{% endif %}"
@@ -111,6 +121,7 @@
111121
card_product: product,
112122
media_aspect_ratio: section.settings.image_ratio,
113123
image_shape: section.settings.image_shape,
124+
lazy_load: lazy_load,
114125
show_secondary_image: section.settings.show_secondary_image,
115126
show_vendor: section.settings.show_vendor,
116127
show_rating: section.settings.show_rating,
@@ -145,6 +156,7 @@
145156
show_vendor: section.settings.show_vendor,
146157
media_aspect_ratio: section.settings.image_ratio,
147158
image_shape: section.settings.image_shape,
159+
lazy_load: false,
148160
placeholder_image: placeholder_image
149161
%}
150162
</li>

0 commit comments

Comments
 (0)