Skip to content

Commit 6038c97

Browse files
docs: update wording on misc. pages
1 parent 143d1e0 commit 6038c97

File tree

19 files changed

+167
-207
lines changed

19 files changed

+167
-207
lines changed

docs/.vitepress/config.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,8 @@ function nav(): DefaultTheme.NavItem[] {
8686
{
8787
text: 'Placeholders',
8888
items: [
89-
{ text: 'BlurHash', link: '/placeholders/blurhash' },
90-
{ text: 'ThumbHash', link: '/placeholders/thumbhash' },
89+
{ text: 'Overview', link: '/placeholders/' },
90+
{ text: 'Hash-Based', link: '/placeholders/hash-based' },
9191
],
9292
},
9393
],
@@ -119,8 +119,8 @@ function nav(): DefaultTheme.NavItem[] {
119119
{
120120
text: 'Advanced',
121121
items: [
122-
{ text: 'Build Flags', link: '/advanced/build-flags' },
123122
{ text: 'Aspect Ratio', link: '/advanced/aspect-ratio' },
123+
{ text: 'Build Flags', link: '/advanced/build-flags' },
124124
],
125125
},
126126
],
@@ -181,8 +181,8 @@ function sidebarGuide(): DefaultTheme.SidebarItem[] {
181181
{
182182
text: 'Placeholders',
183183
items: [
184-
{ text: 'BlurHash', link: '/placeholders/blurhash' },
185-
{ text: 'ThumbHash', link: '/placeholders/thumbhash' },
184+
{ text: 'Overview', link: '/placeholders/' },
185+
{ text: 'Hash-Based', link: '/placeholders/hash-based' },
186186
],
187187
},
188188
{
@@ -199,8 +199,8 @@ function sidebarGuide(): DefaultTheme.SidebarItem[] {
199199
{
200200
text: 'Advanced',
201201
items: [
202-
{ text: 'Build Flags', link: '/advanced/build-flags' },
203202
{ text: 'Aspect Ratio', link: '/advanced/aspect-ratio' },
203+
{ text: 'Build Flags', link: '/advanced/build-flags' },
204204
],
205205
},
206206
{ text: 'Playground', link: 'https://github.com/johannschopplich/unlazy/tree/main/packages/nuxt/playground' },

docs/advanced/build-flags.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ export default defineConfig({
2626

2727
## Disable Hash Decoding <Badge type="info" text="^0.10.0" />
2828

29-
unlazy includes [BlurHash](/placeholders/blurhash) and [ThumbHash](/placeholders/thumbhash) decoding algorithms (from `fast-blurhash` and `thumbhash` packages). If your project doesn't use hash-based placeholders, you can exclude these dependencies entirely:
29+
unlazy includes [BlurHash](/placeholders/hash-based#blurhash) and [ThumbHash](/placeholders/hash-based#thumbhash) decoding algorithms (from `fast-blurhash` and `thumbhash` packages). If your project doesn't use hash-based placeholders, you can exclude these dependencies entirely:
3030

3131
- `__UNLAZY_HASH_DECODING__`: Set to `false` to tree-shake hash decoding code. Default is `true`.
3232

@@ -41,12 +41,12 @@ This flag only affects the main entry point. If you directly import `unlazy/blur
4141

4242
## Disable Client Logging <Badge type="info" text="^0.10.2" />
4343

44-
unlazy will help you locate missing `data-src` or `data-srcset` attributes in your project by logging a warning in the browser console. An example warning message looks like this:
44+
unlazy helps you locate missing `data-src` or `data-srcset` attributes by logging warnings in the browser console. An example warning message looks like this:
4545

4646
```
4747
[unlazy] Missing `data-src` or `data-srcset` attribute: <img>
4848
```
4949

50-
If you want to disable these warnings, you can use the following build flag:
50+
To disable these warnings, use the following build flag:
5151

52-
- `__UNLAZY_LOGGING__`: This flag is set to `true` by default.
52+
- `__UNLAZY_LOGGING__`: Set to `false` to disable warnings. Default is `true`.

docs/advanced/index.md

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
# Advanced Usage
22

3-
This is a collection of recipes for common use cases, since unlazy is a flexible library that can be used in many ways. If you have a use case that is not covered here, please [open an issue](https://github.com/johannschopplich/unlazy/issues).
3+
This section covers advanced configuration options and optimization techniques for unlazy. These topics help you fine-tune performance and behavior for production applications.
44

5-
- [Aspect Ratio for Blurry Placeholders](/advanced/aspect-ratio)
6-
- [Build Flags to Tree-Shake Unused Code](/advanced/build-flags)
5+
## Topics
6+
7+
- **[Aspect Ratio](/advanced/aspect-ratio)** – Prevent CLS with aspect ratio settings for blurry placeholders
8+
- **[Build Flags](/advanced/build-flags)** – Tree-shake unused features to reduce bundle size
9+
10+
If you have a use case not covered here, please [open an issue](https://github.com/johannschopplich/unlazy/issues).

docs/api/index.md

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,10 @@
11
# Overview
22

3-
unlazy provides a number of methods to help you with lazy loading images. The following methods are available:
3+
unlazy provides a number of methods to help you with lazy loading images:
44

55
- [`lazyLoad`](/api/lazy-load) – Lazy load images with automatic placeholder generation
66
- [`autoSizes`](/api/auto-sizes) – Automatically calculate the `sizes` attribute
77
- [`loadImage`](/api/load-image) – Manually load an image before it enters the viewport
88
- [`createPlaceholderFromHash`](/api/create-placeholder-from-hash) – Generate PNG data URI from BlurHash or ThumbHash
9-
10-
## Server-Side Rendering
11-
12-
unlazy supports server-side rendering for BlurHash and ThumbHash strings. This means that you can generate the placeholder images for the `src` attribute during SSR and avoid the [Cumulative Layout Shift](https://web.dev/cls/) (CLS) caused by the images loading after the page has been rendered.
13-
14-
Both the `unlazy/blurhash` and `unlazy/thumbhash` exports provide a `createPngDataUri` function that can be used to generate a PNG data URI for a BlurHash or ThumbHash string, respectively. This function can be used to generate the `src` attribute for the `<img>` element.
15-
16-
- [`createPngDataUri`](/api/blurhash-create-png-data-uri) – Generate a PNG data URI for a BlurHash string
17-
- [`createPngDataUri`](/api/thumbhash-create-png-data-uri) – Generate a PNG data URI for a ThumbHash string
9+
- BlurHash [`createPngDataUri`](/api/blurhash-create-png-data-uri) – Generate PNG data URI for SSR
10+
- ThumbHash [`createPngDataUri`](/api/thumbhash-create-png-data-uri) – Generate PNG data URI for SSR

docs/api/lazy-load.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ The `lazyLoad` function takes a CSS selector, a DOM element, a list of DOM eleme
99
- The `data-src` attribute will be converted to `src`.
1010
2. Processes all images with a `loading="lazy"` attribute.
1111
- Calculates the image's `sizes` attribute if `data-sizes="auto"` is set.
12-
- Generates a blurry placeholder from a [BlurHash](/placeholders/blurhash) or [ThumbHash](/placeholders/thumbhash) string if applicable.
12+
- Generates a blurry placeholder from a [hash-based placeholder](/placeholders/hash-based) (BlurHash or ThumbHash) string if applicable.
1313
3. If the image has a blurry placeholder and is already in the viewport or the visitor is a crawler, it immediately loads the full-quality image.
1414
4. If the image is not yet in the viewport, an event listener is added to load the full-quality image when it enters the viewport.
1515

docs/guide/index.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,4 @@ unlazy ensures that search engines can index the full-quality images by detectin
3030

3131
Head over to the [installation guide](/guide/installation) to learn how to install unlazy in your project. After that, you can check out the [usage guide](/guide/usage) and may take a look at the [API reference](/api/).
3232

33-
If your project is using [BlurHash](https://blurha.sh), you can check out the [BlurHash guide](/placeholders/blurhash) to learn how to use it with unlazy.
34-
35-
The shiny new [ThumbHash](https://github.com/evanw/thumbhash) by Evan Wallace is also supported. You can check out the [ThumbHash guide](/placeholders/thumbhash) to learn how to use it with unlazy.
33+
If you want to use hash-based placeholders like [BlurHash](https://blurha.sh) or [ThumbHash](https://github.com/evanw/thumbhash), check out the [hash-based placeholders guide](/placeholders/hash-based).

docs/guide/installation.md

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -31,20 +31,16 @@ For more use cases, head over to the [Usage](/guide/usage) guide.
3131

3232
## Without a Build Step
3333

34-
unlazy can be used without a build step. Useful for prototyping or when you do not want to add a build step to your project. Simply load it from a CDN:
34+
unlazy can be used without a build step from a CDN. Useful for prototyping or projects without bundlers.
3535

36-
- Global build: <CdnLink name="unlazy.iife.js" />
37-
- Exposes `UnLazy` global property, supports auto initializing
38-
- ESM build: <CdnLink name="unlazy.js" />
39-
- Must be used with `<script type="module">`
36+
**Available Builds:**
37+
- **Standard Global**: <CdnLink name="unlazy.iife.js" /> - Exposes `UnLazy` global, supports auto-initialization
38+
- **Standard ESM**: <CdnLink name="unlazy.js" /> - Requires `<script type="module">`
39+
- **With Hashing Global**: <CdnLink name="unlazy.with-hashing.iife.js" /> - Includes BlurHash/ThumbHash decoders
40+
- **With Hashing ESM**: <CdnLink name="unlazy.with-hashing.js" /> - ESM with hash decoding
4041

4142
::: info
42-
To keep the bundle size small, the standard global build excludes BlurHash and ThumbHash decoding algorithms. Use the `with-hashing` variant if you need client-side hash decoding:
43-
44-
- Global build with hashing: <CdnLink name="unlazy.with-hashing.iife.js" />
45-
- ESM build with hashing: <CdnLink name="unlazy.with-hashing.js" />
46-
47-
If you decode hashes on the server (e.g., during SSR), use the standard bundle instead.
43+
Use standard builds if you decode hashes on the server (SSR). Use `with-hashing` builds only if you need client-side hash decoding.
4844
:::
4945

5046
### Auto-Initialization
@@ -59,12 +55,12 @@ When using the global build, you can use the `init` attribute to automatically i
5955
- The `init` attribute tells the library to automatically initialize and watch all elements that have a `loading="lazy"` attribute.
6056

6157
::: info
62-
The short CDN URLs are meant for prototyping. For production usage, use a fully resolved CDN URL to avoid resolving and redirect cost:
58+
The short CDN URLs are meant for prototyping. For production usage, use a fully resolved CDN URL to avoid resolving and redirect costs, for example: `https://unpkg.com/[email protected]/dist/unlazy.iife.js`.
6359
:::
6460

6561
### Manual Initialization
6662

67-
If you do not want the auto-initialize the library, remove the `init` attribute and move the scripts to end of the `<body>` tag:
63+
If you do not want to auto-initialize the library, remove the `init` attribute and move the scripts to end of the `<body>` tag:
6864

6965
```html
7066
<script src="https://unpkg.com/unlazy"></script>
@@ -74,7 +70,7 @@ If you do not want the auto-initialize the library, remove the `init` attribute
7470
```
7571

7672
::: info
77-
The short CDN URLs are meant for prototyping. For production usage, use a fully resolved CDN URL to avoid resolving and redirect cost:
73+
The short CDN URLs are meant for prototyping. For production usage, use a fully resolved CDN URL to avoid resolving and redirect costs, for example: `https://unpkg.com/[email protected]/dist/unlazy.iife.js`.
7874
:::
7975

8076
## Example

docs/guide/seo-considerations.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
# SEO Considerations
22

3-
When implementing lazy loading with blurry placeholders, it is important to consider the impact it may have on SEO. Search engine bots and crawlers are responsible for indexing and ranking your website's content, and they might not always behave like human visitors when browsing the site. unlazy ensures that your website's images are indexed correctly and that their quality is not negatively affected by the use of blurry placeholders.
3+
When implementing lazy loading with blurry placeholders, consider the SEO impact. Search engine bots and crawlers may not behave like human visitors. unlazy ensures images are indexed correctly without compromising quality due to blurry placeholders.
44

55
## Detects Bots and Crawlers
66

7-
unlazy includes an exported function called `isCrawler` that detects if the visitor is a bot or a crawler. This ensures that the full-quality image is loaded and indexed by search engines.
7+
unlazy includes an exported `isCrawler` function that detects bots and crawlers, ensuring full-quality images are loaded and indexed by search engines.
88

99
The detection mechanism works by:
1010

@@ -16,6 +16,6 @@ The library trusts that bots and crawlers can evaluate the `srcset` attribute an
1616

1717
## Use `src`, `data-srcset` and `sizes`, or `data-src` Attributes
1818

19-
When using blurry placeholders, it is important to set the `src` attribute with the blurry placeholder image and use the `data-srcset` (or `data-src`) attribute for the high-quality image. This ensures that the initial rendering of the page will display the blurry placeholders, while the full-quality images will be loaded later as they enter the viewport.
19+
Set the `src` attribute with the blurry placeholder and use `data-srcset` (or `data-src`) for the high-quality image. This displays placeholders during initial render while loading full-quality images as they enter the viewport.
2020

21-
Additionally, using the `sizes` attribute (or [`data-sizes="auto"`](/guide/usage#auto-calculation-of-the-sizes-attribute) for automatic calculation) helps provide the search engine with information about the intended display size of the image. This enables search engines to select the most appropriate image source from the `srcset` attribute when indexing your website's content.
21+
Use the `sizes` attribute (or [`data-sizes="auto"`](/guide/usage#auto-calculation-of-the-sizes-attribute) for automatic calculation) to provide search engines with the intended display size. This enables search engines to select the appropriate image source from the `srcset` attribute when indexing.

docs/guide/usage.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
1. Add the `loading="lazy"` attribute to a `<img>` element that you want to lazily load. You can also use the `<picture>` element to lazily load images in different formats.
44

5-
2. Use the `data-src` or `data-srcset` attribute to specify the high-quality image. These data attributes prevent browsers from loading images before they enter the viewport and are swapped to standard attributes by unlazy when loading occurs.
5+
2. Use `data-src` or `data-srcset` attributes to specify the high-quality image. These prevent browsers from loading images before they enter the viewport and are swapped to standard attributes when loading occurs.
66

7-
3. If you have a pre-generated blurry placeholder image, use the `src` attribute to specify it. Otherwise, you can use a [BlurHash](/placeholders/blurhash) or [ThumbHash](/placeholders/thumbhash) to generate a placeholder image on the fly.
7+
3. Set the `src` attribute with a pre-generated blurry placeholder, or use [hash-based placeholders](/placeholders/hash-based) (BlurHash or ThumbHash) to generate placeholders on the fly.
88

99
::: code-group
1010
```html [Image tag]
@@ -51,7 +51,7 @@ const cleanup = lazyLoad()
5151
// Useful when unmounting components or removing images dynamically
5252
```
5353

54-
The `lazyLoad` function returns a cleanup function that removes all event listeners and ResizeObservers. Call this function when unmounting components or when images are no longer needed to prevent memory leaks.
54+
The `lazyLoad` function returns a cleanup function that removes event listeners and ResizeObservers. Call this when unmounting components or removing images to prevent memory leaks.
5555

5656
## Auto Calculation of the `sizes` Attribute
5757

@@ -68,9 +68,9 @@ The automatic sizes calculation uses the display width of the image.
6868
>
6969
```
7070

71-
When calling [`lazyLoad`](/api/lazy-load), the library will automatically calculate the `sizes` attribute for all images with `data-sizes="auto"`.
71+
When calling [`lazyLoad`](/api/lazy-load), the library automatically calculates the `sizes` attribute for all images with `data-sizes="auto"`.
7272

73-
Alternatively, you can use the [`autoSizes`](/api/auto-sizes) function to calculate the `sizes` attribute for all images with `data-sizes="auto"`, without lazy loading the images.
73+
Alternatively, use the [`autoSizes`](/api/auto-sizes) function to calculate the `sizes` attribute without lazy loading.
7474

7575
To do so, import the [`autoSizes`](/api/auto-sizes) function from the library and call it:
7676

@@ -113,5 +113,5 @@ loadImage(coolImage)
113113
```
114114

115115
::: tip
116-
Keep in mind that manually loading images might negatively affect the perceived performance, as it will force the full-quality image to load immediately, even if it is not visible on the viewport.
116+
Manually loading images may negatively affect perceived performance by forcing immediate load, even when not visible in the viewport.
117117
:::

docs/integrations/index.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
unlazy supports lazy loading images in your framework of choice. Each package provides a `UnLazyImage` component as a drop-in replacement for the native `<img>` element.
44

5-
## Generic How-To
5+
## Creating Custom Integrations
66

7-
To create a component for the framework of your choice, keep the following in mind:
7+
To create a component for your framework, keep the following in mind:
88

99
1. The component should wrap a native `<img>` element with the `loading="lazy"` attribute set.
1010
2. The component should support at least a `src` or `srcset` attribute.
@@ -60,7 +60,7 @@ The following integrations are available as of now:
6060
### Meta-Frameworks
6161

6262
::: tip
63-
These include SSR-decoding of [BlurHash](/placeholders/blurhash) and [ThumbHash](/placeholders/thumbhash) strings.
63+
These include SSR-decoding of [hash-based placeholders](/placeholders/hash-based) (BlurHash and ThumbHash).
6464
:::
6565

6666
- [Nuxt](/integrations/nuxt)

0 commit comments

Comments
 (0)