You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Jul 27, 2024. It is now read-only.
Copy file name to clipboardExpand all lines: docs/checks/img_lazy_loading.md
+7-5Lines changed: 7 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,17 +8,19 @@ Very often, webpages contain many images that contribute to data-usage and how f
8
8
9
9
_Quoted from [MDN - Lazy loading][mdn]_
10
10
11
+
As a general rule you should apply `loading="lazy"` to elements that are **not initially visible** when the page loads. Only images that require user interaction (scrolling, hovering, clicking etc.) to be seen can be safely lazy loaded without negatively impacting the rendering performance.
12
+
11
13
## Check Details
12
14
13
-
This check is aimed at defering loading non-critical images.
15
+
This check is aimed at deferring loading non-critical images.
14
16
15
17
:-1: Examples of **incorrect** code for this check:
16
18
17
19
```liquid
18
20
<img src="a.jpg">
19
21
20
-
<!-- Replaces lazysize.js -->
21
-
<img src="a.jpg" class="lazyload">
22
+
<!-- Replaces lazysizes.js -->
23
+
<img data-src="a.jpg" class="lazyload">
22
24
23
25
<!-- `auto` is deprecated -->
24
26
<img src="a.jpg" loading="auto">
@@ -29,7 +31,7 @@ This check is aimed at defering loading non-critical images.
29
31
```liquid
30
32
<img src="a.jpg" loading="lazy">
31
33
32
-
<!-- `eager` is also accepted, but prefer `lazy` -->
34
+
<!-- `eager` is also accepted -->
33
35
<img src="a.jpg" loading="eager">
34
36
```
35
37
@@ -44,7 +46,7 @@ ImgLazyLoading:
44
46
45
47
## When Not To Use It
46
48
47
-
If you don't want to defer loadingof images, then it's safe to disable this rule.
49
+
There should be no cases where disabling this rule is needed. When it comes to rendering performance, it is generally better to specify `loading="eager"` as a default. You may want to do that for sections that are often placed in different parts of the page (top, middle, bottom), which makes it hard to reason about which value should be used.
0 commit comments