An open API service indexing awesome lists of open source software.

https://github.com/krutsch/progressive-picture

Native Lazy Loaded Picture Element with Progressive Image Change
https://github.com/krutsch/progressive-picture

dom element image intersectionobserver lazyload mutationobserver picture pictures progressive progressive-image-loading

Last synced: about 2 months ago
JSON representation

Native Lazy Loaded Picture Element with Progressive Image Change

Awesome Lists containing this project

README

        

# Progressive Picture

> This 700 bytes (compressed) library enhances `Picture Elements` with Progressive Image Loading and thus improves the initial time of images being displayed.
> You can find out more from the [blog post](https://dev.to/fabkrut/enhancing-images-on-the-web-3b35).

## Install via NPM

```
$ npm install progressive-picture
```

## Install via Script Tag

```

```

## Add the styles

```css
picture > img {
display: block;
max-width: 100%;
height: auto;
filter: blur(0);
transition: filter 0.7s ease-in;
}
picture > img[data-src] {
filter: blur(3px);
}
picture > img.img-progressive {
width: auto;
}
```

## Example

```html



```

### Demo

https://lazy-load-picture.netlify.app/
https://lazy-load-picture.netlify.app/masonry.html

## Usage

The `srcset` of `` and the `src` of `` has to be filled with the URI for the low-quality image (or in case of the `` element: a `srcset` of low quality preview pictures. The data-src holds the high-quality image(s) and will be replaced once it has been loaded.
Also, there is a data-alt Attribute that can be applied as alt, once the Image was replaced. This fixes the inelegance of displaying text before an image appears.

### Further Optimization

While this library is useful on the Web, optimizing the image correctly in the build step is the other side of the coin. This plugin [snowpack-plugin-sharp](https://www.npmjs.com/package/snowpack-plugin-sharp) could be helpful in this case.