Skip to content

Commit e4720d3

Browse files
committed
Add why section
1 parent 16e33b5 commit e4720d3

1 file changed

Lines changed: 22 additions & 5 deletions

File tree

README.md

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,18 @@
11
# Docusaurus Native Ideal Image Plugin
22

3-
A [Docusaurus](https://docusaurus.io/) plugin for pre-processing images to multiple formats, sizes and low quality image placeholders, replacing [ideal-image](https://docusaurus.io/docs/api/plugins/@docusaurus/plugin-ideal-image)
3+
A [Docusaurus](https://docusaurus.io/) plugin for pre-processing images to multiple formats, sizes and low quality image placeholders
4+
5+
This replaces the official [@docusaurus/plugin-ideal-image](https://docusaurus.io/docs/api/plugins/@docusaurus/plugin-ideal-image) through modern browser native [`srcset`](https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/srcset) and [lazy loading](https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/img#loading)
6+
7+
## Why
8+
9+
The official [@docusaurus/plugin-ideal-image](https://docusaurus.io/docs/api/plugins/@docusaurus/plugin-ideal-image) has some limitations and bugs which this package was made to solve:
10+
11+
- [Image flashing when navigating back and forward](https://github.com/facebook/docusaurus/issues/10214)
12+
- Buggy low bandwidth detection that replaces the image with a 'Click to load' text instead of just loading it.
13+
- Doesn't support newer image formats that has better compression ratios like WebP and AVIF
14+
15+
Apart from these, using browser native features is more performant, and resulting in smaller bundle sizes
416

517
## Usage
618

@@ -55,11 +67,16 @@ By default, this will transform the image into a jpeg source and a webp source a
5567

5668
```html
5769
<picture
58-
class="native-ideal-img"
59-
style="--lqip: url(data:image/webp;base64,UklGRj4AAABXRUJQVlA4IDIAAADQAQCdASoQAAwABUB8JZQAAudcoVPyIAD+uVyF4iJZsGTWpdieB7utExa6oMeh0PusAA==);"
70+
class="native-ideal-img"
71+
style="--lqip: url(data:image/webp;base64,UklGRj4AAABXRUJQVlA4IDIAAADQAQCdASoQAAwABUB8JZQAAudcoVPyIAD+uVyF4iJZsGTWpdieB7utExa6oMeh0PusAA==);"
6072
>
61-
<source srcset="assets/native-ideal-image/some-image-b0600-2160.webp" type="image/webp" />
62-
<img loading="lazy" src="assets/native-ideal-image/some-image-6ee75-2160.jpeg" width="2160" height="1620" />
73+
<source srcset="assets/native-ideal-image/some-image-b0600-2160.webp" type="image/webp" />
74+
<img
75+
loading="lazy"
76+
src="assets/native-ideal-image/some-image-6ee75-2160.jpeg"
77+
width="2160"
78+
height="1620"
79+
/>
6380
</picture>
6481
```
6582

0 commit comments

Comments
 (0)