Skip to content

Commit 0ba7eae

Browse files
committed
updated README
1 parent bcc7735 commit 0ba7eae

File tree

2 files changed

+51
-29
lines changed

2 files changed

+51
-29
lines changed

LICENSE

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2017 Apoorv Saxena
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

+30-29
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,34 @@
1-
Lozad [![npm version](https://badge.fury.io/js/lozad.svg)](https://badge.fury.io/js/lozad)
2-
=====
3-
*Advanced performant Lazy Loader using Intersection Observer API*
4-
***
1+
# Lozad.js [![npm version](https://badge.fury.io/js/lozad.svg)](https://badge.fury.io/js/lozad)
2+
3+
> Highly performant, light ~0.5kb and configurable lazy loader in pure JS with no dependencies for images, iframes and more, using IntersectionObserver API
54
65
![lozad.js lazy loading javascript library](./banner/lozad-banner.png "lozad.js lazy loading javascript library")
76

7+
**Lozad.js**:
8+
- lazy loads elements performantly using pure JavaScript,
89
- is a light-weight library, *just **535 bytes*** minified & gzipped,
910
- has NO DEPENDENCIES :)
10-
- lazy loads elements performantly using pure JavaScript.
11+
- allows lazy loading of dynamically added elements as well.
1112

12-
It is written with an aim to lazy load images, 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) with tremendous performance benefits.
13+
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) with tremendous performance benefits.
1314

14-
Yet another Lazy Loading JavaScript library, why?
15-
-----
16-
Existing lazy loading libraries hook up 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.
15+
## Table of Contents
1716

18-
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.
17+
- [Demo](https://apoorv.pro/lozad.js/demo/)
18+
- [Background](#yet-another-lazy-loading-javascript-library-why)
19+
- [Get started](#get-started)
20+
- [Usage](#usage)
21+
- [Browser Support](#browser-support)
22+
- [Contribute](#contribute)
23+
- [Changelog](#changelog)
24+
- [License](#license)
1925

20-
[Demo](https://apoorv.pro/lozad.js/demo/index.html)
21-
-----
26+
## Yet another Lazy Loading JavaScript library, why?
27+
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.
28+
29+
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.
2230

23-
Get Started
24-
-----
31+
## Get Started
2532

2633
Get the library using one of the following ways:
2734

@@ -51,10 +58,9 @@ or
5158
<script type="text/javascript" src="lozad.min.js"></script>
5259
```
5360

54-
**Note**: **lozad.js** supports AMD and commonJS module pattern out of the box.
61+
**Note**: `lozad.js` supports AMD and commonJS module pattern out of the box.
5562

56-
Usage
57-
-----
63+
## Usage
5864

5965
In HTML, add an identifier to the element (default selector identified is `lozad` class):
6066
```html
@@ -63,14 +69,14 @@ In HTML, add an identifier to the element (default selector identified is `lozad
6369

6470
All you need to do now is just instantiate Lozad as follows:
6571
```js
66-
const observer = lozad(); // lazy loads elements with selector as '.lozad'
72+
const observer = lozad(); // lazy loads elements with default selector as '.lozad'
6773
observer.observe();
6874
```
6975
or with custom options:
7076
```js
7177
const observer = lozad('.lozad', {
7278
rootMargin: '10px 0px', // syntax similar to that of CSS Margin
73-
threshold: 0.1 // ratio of image convergence
79+
threshold: 0.1 // ratio of element convergence
7480
});
7581
observer.observe();
7682
```
@@ -100,25 +106,20 @@ observer.observe();
100106
// ... code to dynamically add elements
101107
observer.observe(); // observes newly added elements as well
102108
```
103-
Browser Support
104-
-----
109+
## Browser Support
105110

106111
Available in [latest browsers](http://caniuse.com/#feat=intersectionobserver). If browser support is not available, then make use of this [polyfill](https://www.npmjs.com/package/intersection-observer).
107112

108-
Contributing
109-
-----
113+
## Contribute
110114

111115
Interested in contributing features and fixes?
112116

113117
[Read more on contributing](./CONTRIBUTING.md).
114118

115-
Changelog
116-
-----
119+
## Changelog
117120

118121
See the [Changelog](https://github.com/ApoorvSaxena/lozad.js/wiki/Changelog)
119122

120-
License
121-
-----
123+
## License
122124

123-
Copyright (c) 2017 Apoorv Saxena, https://apoorv.pro
124-
Licensed under the [MIT license](http://opensource.org/licenses/MIT).
125+
[MIT](LICENSE) © [Apoorv Saxena](https://apoorv.pro)

0 commit comments

Comments
 (0)