Skip to content

Commit

Permalink
Use the new Liquid section properties
Browse files Browse the repository at this point in the history
to improve LCP
  • Loading branch information
montalvomiguelo committed Oct 13, 2023
1 parent 0dc3a3a commit 6b83a55
Showing 1 changed file with 7 additions and 19 deletions.
26 changes: 7 additions & 19 deletions sections/image-banner.liquid
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@
assign banner_class = 'h-screen-no-nav'
endif

assign loading = 'lazy'
unless section.settings.lazy_load_enable
assign loading = 'eager'
endunless
assign preload = true
assign loading = 'eager'
if section.index0 > 0
assign loading = 'lazy'
assign preload = false
endif
-%}

<div id="Banner-{{ section.id }}" class="relative flex w-full flex-col justify-end {{ banner_class }}">
Expand All @@ -27,7 +29,7 @@
| image_url: width: 1500
| image_tag:
loading: loading,
preload: section.settings.preload_first_image_enable,
preload: preload,
width: section.settings.image.width,
height: image_height,
class: 'block object-cover w-full h-full',
Expand Down Expand Up @@ -120,20 +122,6 @@
"id": "full_page_height_enable",
"default": true,
"label": "Full page height"
},
{
"type": "checkbox",
"id": "lazy_load_enable",
"default": true,
"label": "Lazy load",
"info": "The images aren't loaded until they're almost in view."
},
{
"type": "checkbox",
"id": "preload_first_image_enable",
"default": false,
"label": "Preload first image",
"info": "Preload the largest contentful paint image."
}
],
"blocks": [
Expand Down

0 comments on commit 6b83a55

Please sign in to comment.