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

https://github.com/webreflection/with-preview

An <img> built-in extend that loads its non-preview counterpart once visible
https://github.com/webreflection/with-preview

Last synced: over 1 year ago
JSON representation

An <img> built-in extend that loads its non-preview counterpart once visible

Awesome Lists containing this project

README

          

# with-preview

![frozen beach](./test/with-preview.jpg)

**Photo by [Pierre Bouillot](https://unsplash.com/@pbouillot) on [Unsplash](https://unsplash.com/)**

A built-in Custom Element based on _IntersectionObserver_ able to fade in good quality jpg over their preview version.

It fallbacks all the way down to IE 9, simply replacing on the fly the preview source with its good quality counter-part.

**[Live demo](https://webreflection.github.io/with-preview/test/)**

### Example

```html


```

Images will drop the `.preview` part of the _src_ and will fade in the non `.preview` version of the same image once the document shows the preview, and after the non-preview version is loaded.

Previews can be manually generated or based on [µcompress](https://github.com/WebReflection/ucompress#readme) or [µcdn](https://github.com/WebReflection/ucdn#readme) previews.

```sh
# example: will create test.preview.jpg
npx ucompress --preview --source test.jpg
```