Skip to content

Commit e23a6d6

Browse files
author
Hendrik Haack
authored
Fix typo, consistent code style in examples (#248)
* Fix typo, consistent code style in examples
1 parent 146b6ba commit e23a6d6

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

Diff for: README.md

+9-7
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
It is written with an aim to lazy load images, iframes, ads, videos or any other element using the recently added [Intersection Observer API](https://developer.mozilla.org/en-US/docs/Web/API/Intersection_Observer_API) and [MutationObserver](https://developer.mozilla.org/en-US/docs/Web/API/MutationObserver) with tremendous performance benefits.
1818

1919
## Featured in:
20+
2021
- [Web | Google Developers](https://developers.google.com/web/fundamentals/performance/lazy-loading-guidance/images-and-video/)
2122
- [Product Hunt](https://www.producthunt.com/posts/lozad-js)
2223
- [Reddit](https://www.reddit.com/r/webdev/comments/6zg1x0/highly_performant_light_05kb_and_configurable/)
@@ -26,6 +27,7 @@ It is written with an aim to lazy load images, iframes, ads, videos or any other
2627
- [SitePoint](https://www.sitepoint.com/five-techniques-lazy-load-images-website-performance/)
2728

2829
## Brands using Lozad.js:
30+
2931
![Tesla](./brands/tesla.png)          ![Binance](./brands/binance.png)          ![Domino's](./brands/dominos.png)         
3032
![BNP Paribas](./brands/bnp-paribas.png)          ![Mi](./brands/xiaomi.png)         
3133
![Amway](./brands/amway.png)          ![TATA](./brands/tata.png)          ![Verizon](./brands/verizon.svg)
@@ -34,7 +36,6 @@ It is written with an aim to lazy load images, iframes, ads, videos or any other
3436

3537
and many more...
3638

37-
3839
## Table of Contents
3940

4041
- [Demo](https://apoorv.pro/lozad.js/demo/)
@@ -49,6 +50,7 @@ and many more...
4950
- [License](#license)
5051

5152
## Yet another Lazy Loading JavaScript library, why?
53+
5254
Existing lazy loading libraries hook up to the scroll event or use a periodic timer and call `getBoundingClientRect()` on elements that need to be lazy loaded. This approach, however, is painfully slow as each call to `getBoundingClientRect()` forces the browser to re-layout the entire page and will introduce considerable jank to your website.
5355

5456
Making this more efficient and performant is what [IntersectionObserver](https://developers.google.com/web/updates/2016/04/intersectionobserver) is designed for, and it’s landed in Chrome 51. IntersectionObservers let you know when an observed element enters or exits the browser’s viewport.
@@ -94,7 +96,7 @@ When loading from CDN, you can find the library on `window.lozad`.
9496

9597
In HTML, add an identifier to the element (default selector identified is `lozad` class):
9698
```html
97-
<img class="lozad" data-src="image.png" />
99+
<img class="lozad" data-src="image.png">
98100
```
99101

100102
All you need to do now is just instantiate Lozad as follows:
@@ -112,7 +114,7 @@ or with custom options:
112114
```js
113115
const observer = lozad('.lozad', {
114116
rootMargin: '10px 0px', // syntax similar to that of CSS Margin
115-
threshold: 0.1 // ratio of element convergence
117+
threshold: 0.1, // ratio of element convergence
116118
enableAutoReload: true // it will reload the new image when validating attributes changes
117119
});
118120
observer.observe();
@@ -160,7 +162,7 @@ for use with responsive images
160162

161163
```html
162164
<!-- responsive image example -->
163-
<img class="lozad" data-src="image.png" data-srcset="image.png 1000w, image-2x.png 2000w" />
165+
<img class="lozad" data-src="image.png" data-srcset="image.png 1000w, image-2x.png 2000w">
164166
```
165167

166168
for use with background images
@@ -201,7 +203,7 @@ If you want to load the images before they appear:
201203
const observer = lozad();
202204
observer.observe();
203205

204-
const coolImage = document.querySelector('.image-to-load-first')
206+
const coolImage = document.querySelector('.image-to-load-first');
205207
// ... trigger the load of a image before it appears on the viewport
206208
observer.triggerLoad(coolImage);
207209
```
@@ -211,7 +213,7 @@ observer.triggerLoad(coolImage);
211213
Sometimes image loading takes a long time. For this case, you can add a placeholder background:
212214

213215
```html
214-
<img class="lozad" data-placeholder-background="red" data-src="image.png" />
216+
<img class="lozad" data-placeholder-background="red" data-src="image.png">
215217
```
216218

217219
Lozad sets a placeholder background color of img element and users will see the fallback till the image loads.
@@ -247,7 +249,7 @@ If you want to use image placeholder (like low quality image placeholder), you c
247249
<source srcset="images/thumbs/05.jpg" media="(min-width: 980px)">
248250
<source srcset="images/thumbs/06.jpg" media="(min-width: 320px)">
249251
<!-- you can define a low quality image placeholder that will be removed when the picture is loaded -->
250-
<img src="data:image/jpeg;base64,/some_lqip_in_base_64==" />
252+
<img src="data:image/jpeg;base64,/some_lqip_in_base_64==">
251253
</picture>
252254
```
253255

0 commit comments

Comments
 (0)