Skip to content

Commit 424b68c

Browse files
committed
Remove lazysizes and use browser-default lazyloading
1 parent 0ae03c5 commit 424b68c

File tree

1 file changed

+12
-37
lines changed

1 file changed

+12
-37
lines changed
Lines changed: 12 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,7 @@
11
{{!--
2-
This file implements the lazysizes srcset pattern (as seen on
3-
https://github.com/aFarkas/lazysizes#modern-transparent-srcset-pattern) for maximum performance on modern browsers
4-
and reasonable compatibility with legacy browsers.
5-
62
There are a few important arguments to know about when using this component:
73
`lazyload`:
8-
- If set to 'lazyload+lqip', will load a low-res image which will be replaced by lazysizes - ensuring that SOME
9-
content is shown immediately on page load. Without LQIP, a transparent gif will be used instead, which reduces
10-
the number of requests needed to load the page, making it even faster.
11-
- If set to 'lazyload', the browser will not load the full-size image at first, instead the lazysizes plugin will
12-
load it progressively after page load. This improves the load speed of the page, but it should be disabled for
13-
high-priority above-the-fold images.
4+
- If set to 'lazyload', the browser will make a decision about when to load the image based on whether its proximity to the viewport.
145
- If set to 'disabled', will not attempt to lazyload the image and instead tell the browser to load it immediately.
156
Use this for high-priority images that are above the fold.
167

@@ -30,32 +21,16 @@
3021
path in the theme config. If a default image is not provided, you'll get an image tag with no image if the primary
3122
image is undefined.
3223

33-
`lqip_size`:
34-
If you want to specify a particular size for the LQIP image, you can do so with this argument. A default of 80
35-
pixels wide will be used otherwise. This argument has no effect if the lazyload mode is not "lazyload+lqip".
36-
37-
--}}
38-
<img {{#if image}}{{!-- Get the default image for legacy browsers that do not support srcset
39-
--}}src="{{getImageSrcset image 1x=(default fallback_size '160w')}}" alt="{{image.alt}}" title="{{image.alt}}" {{!--
40-
Allow lazysizes to generate the 'sizes' attribute automatically --}}data-sizes="auto"
41-
{{#unless lazyload '==' 'disabled'}}
42-
{{#if lazyload '==' 'lazyload+lqip'}}
43-
{{!-- If we want a LQIP, include it as the default srcset (will be overwritten by lazysizes) --}}
44-
srcset="{{getImageSrcset image 1x=(default lqip_size '80w')}}"
45-
{{else}}
46-
{{!-- If we don't want a LQIP, use a 1px transparent gif for the stand-in image
47-
This requires no additional network request, so it's fast --}}
48-
srcset="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw=="
49-
{{/if}}
50-
{{/unless}}
51-
{{!-- If lazyloading is disabled, just use "srcset". If it is not disabled, use "data-srcset" so lazysizes will use
52-
this after page load --}}
53-
{{!--
54-
Generate the srcset string using the default sizes defined in the helper. This will allow the browser to
55-
pick the best-sized image based on its own understanding of how it will render the page.
5624
--}}
57-
{{#unless lazyload '==' 'disabled'}}data-{{/unless}}srcset="{{getImageSrcset image use_default_sizes=true }}"
58-
{{else if default_image}}src="{{cdn default_image}}" alt="{{lang 'products.card_default_image_alt'}}"{{/if}}
59-
class="{{#unless lazyload '==' 'disabled'}}lazyload{{/unless}}{{#if class}} {{class}}{{/if}}"
60-
{{#if lazyload '==' 'lazyload'}}loading="lazy"{{/if}}
25+
<img {{#if image}}{{!-- Get the default image for legacy browsers that do not support srcset --}}
26+
src="{{getImageSrcset image 1x=(default fallback_size '160w')}}" alt="{{image.alt}}" title="{{image.alt}}"
27+
{{!--
28+
Generate the srcset string using the default sizes defined in the helper. This will allow the browser to
29+
pick the best-sized image based on its own understanding of how it will render the page.
30+
--}}
31+
srcset="{{getImageSrcset image use_default_sizes=true }}"
32+
{{else if default_image}}src="{{cdn default_image}}" alt="{{lang 'products.card_default_image_alt'}}"
33+
{{/if}}
34+
class="{{#if class}}{{class}}{{/if}}"
35+
{{#unless lazyload '==' 'disabled'}}loading="lazy"{{/unless}}
6136
{{otherAttributes}} />

0 commit comments

Comments
 (0)