Skip to content
This repository was archived by the owner on Feb 6, 2024. It is now read-only.

Commit 91b5813

Browse files
doc(#119): lazy load images using native lazy-loading
1 parent 29ad84c commit 91b5813

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

docs/docs/components/app-components-lazy-img/app-components-lazy-img.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
The "Lazy Image" component is a dead simple component to lazy load images.
44

5-
It leverages the IntersectionObserver API to lazy load images and also allows you to trigger "manually" their loading.
5+
It leverages the native lazy-loading when available and the IntersectionObserver API as fallback to lazy load images. It also allows you to trigger "manually" their loading.
66

77
An `<img/>` tag is per default use to display the image but optionally it could parse `SVG` too.
88

@@ -44,6 +44,7 @@ This component offers the following options which could be set using attributes:
4444
| aria-label | string | | If you are using the above SVG option, provide the accessibility information using this attribute |
4545
| observer-root-margin | string | 100px 0px | A string which specifies a set of offsets to add to the root's bounding_box when calculating intersections, effectively shrinking or growing the root for calculation purposes. [More info.](https://developer.mozilla.org/en-US/docs/Web/API/IntersectionObserver/IntersectionObserver) |
4646
| observer-threshold | number or number[] | | Either a single number or an array of numbers between 0.0 and 1.0, specifying a ratio of intersection area to total bounding box area for the observed target. [More info.](https://developer.mozilla.org/en-US/docs/Web/API/IntersectionObserver/IntersectionObserver) |
47+
| intrinsicsize | string | An intrinsicsize for the native lazy-loading (see [Native lazy-loading for the web](https://web.dev/native-lazy-loading))
4748

4849
### Theming
4950

@@ -76,7 +77,7 @@ await element.lazyLoad();
7677

7778
### Fallback
7879

79-
In case the browsers would not support the Intersection Observer, images are going to be loaded without any delay when the component load respectively if the browser does not implement the Intersection Observer API images are displayed and not lazy loaded.
80+
In case the browser would not support the native native lazy-loading or the Intersection Observer API, images are going to be loaded without any delay when the component load respectively if the browser does not implement the Intersection Observer API images are displayed and not lazy loaded.
8081

8182
### Trying it out
8283

docs/src/app/pages/docs/components/app-components-lazy-img/app-components-lazy-img.tsx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ export class AppComponentsLazyImg {
3232
<ion-content class="ion-padding">
3333
<main><h1 id="app-components-lazy-img-lazy-image">Lazy Image</h1>
3434
<p>The &quot;Lazy Image&quot; component is a dead simple component to lazy load images.</p>
35-
<p>It leverages the IntersectionObserver API to lazy load images and also allows you to trigger &quot;manually&quot; their loading.</p>
35+
<p>It leverages the native lazy-loading when available and the IntersectionObserver API as fallback to lazy load images. It also allows you to trigger &quot;manually&quot; their loading.</p>
3636
<p>An <code>&lt;img/&gt;</code> tag is per default use to display the image but optionally it could parse <code>SVG</code> too.</p>
3737
<h2 id="app-components-lazy-img-table-of-contents">Table of contents</h2>
3838
<ul>
@@ -117,6 +117,12 @@ export class AppComponentsLazyImg {
117117
<td></td>
118118
<td>Either a single number or an array of numbers between 0.0 and 1.0, specifying a ratio of intersection area to total bounding box area for the observed target. <a href="https://developer.mozilla.org/en-US/docs/Web/API/IntersectionObserver/IntersectionObserver">More info.</a></td>
119119
</tr>
120+
<tr>
121+
<td>intrinsicsize</td>
122+
<td>string</td>
123+
<td>An intrinsicsize for the native lazy-loading (see <a href="https://web.dev/native-lazy-loading">Native lazy-loading for the web</a>)</td>
124+
<td></td>
125+
</tr>
120126
</tbody></table>
121127
<h3 id="app-components-lazy-img-theming">Theming</h3>
122128
<p>The following theming options will affect this component if set on its host or parent.</p>
@@ -199,7 +205,7 @@ export class AppComponentsLazyImg {
199205
<deckgo-highlight-code language="javascript">
200206
<code slot="code">const element = document.querySelector(&#039;deckgo-lazy-img&#039;);{'\n'}await element.lazyLoad();</code>
201207
</deckgo-highlight-code><h3 id="app-components-lazy-img-fallback">Fallback</h3>
202-
<p>In case the browsers would not support the Intersection Observer, images are going to be loaded without any delay when the component load respectively if the browser does not implement the Intersection Observer API images are displayed and not lazy loaded. </p>
208+
<p>In case the browser would not support the native native lazy-loading or the Intersection Observer API, images are going to be loaded without any delay when the component load respectively if the browser does not implement the Intersection Observer API images are displayed and not lazy loaded. </p>
203209
<h3 id="app-components-lazy-img-trying-it-out">Trying it out</h3>
204210
<p>This component lazy load images when these are not presented in the viewport. If you would use this component in a simple test containing only a couple of images, respectively no content or no real use case where the images are effectively offscreen, assign a default height to components in order to ensure that some are effectively placed outside of the window <a href="https://github.com/deckgo/deckdeckgo/issues/128#issuecomment-493979841">[#128]</a>.</p>
205211
</main>

0 commit comments

Comments
 (0)