Skip to content
This repository has been archived by the owner on Dec 11, 2023. It is now read-only.

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
nicross committed Aug 21, 2019
1 parent 765e5d7 commit 9b5948a
Showing 1 changed file with 19 additions and 15 deletions.
34 changes: 19 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,27 +1,31 @@
# Lazily.js
A lazy loader for lazy folks.
Inspired by [this tutorial](https://shiftbacktick.io/code/2019/08/17/lazily-lazy-loading.html).

This library leverages a `MutationObserver` to detect when elements are added to the DOM.
This library leverages a `MutationObserver` to detect when its target elements are added to the DOM.
If the native `loading` attribute is supported, then it is applied.
Otherwise an `IntersectionObserver` is used to load elements as needed.
Otherwise an `IntersectionObserver` is used to load them as needed.

## Browser compatibility
## Compatibility
- Compatible with all evergreen browsers
- For IE11 compatibility, please provide polyfills for `IntersectionObserver` and `MutationObserver`
- Otherwise encourage your users to dump their outdated browsers
- For IE11, please provide polyfills for `IntersectionObserver` and `MutationObserver`
- Earlier browsers may require transpilation and additional polyfills

## Standard usage
Simply add the minified script to the document `<head>`:
## Usage
Simply add the minified script to the document `<head>`.
For certain setups, it may be advantageous to include it inline:

```html
<script src=".../dist/Lazily.min.js"></script>
<head>
<script src=".../dist/Lazily.min.js"></script>
</head>
```

For certain setups, it may be advantageous to include it inline.
No other markup changes are required.
It will automatically lazy load `<iframe>`, `<img>`, `<picture>`, and `<video>` elements in supported browsers.

### API
- `Lazily.forceLoad()` - Forces all observed elements to load.
- `Lazily.isSupported()` - Returns `true` if the library is working.

## Next steps
- JSDoc comment blocks
- Contribution guidelines
- Integrations tests
- Uglification build step within the `dist/` directory
## Credits
Inspired by [this tutorial](https://shiftbacktick.io/code/2019/08/17/lazily-lazy-loading.html).

0 comments on commit 9b5948a

Please sign in to comment.