Skip to content
ํ”„๋กœ์ ํŠธ

์†Œ๊ฐœ

๐Ÿชง BlurHash ๋ฐ ThumbHash ํ”Œ๋ ˆ์ด์Šคํ™€๋”๋ฅผ ์‚ฌ์šฉํ•˜๋Š” ๋„ค์ดํ‹ฐ๋ธŒ ์ด๋ฏธ์ง€ ์ง€์—ฐ ๋กœ๋”ฉ โ€” ๋ฐ”๋‹๋ผ JS, Vue, React, Svelte, Solid, Nuxt ์ง€์›

์›น ๋ฐ ์•ฑ ๊ฐœ๋ฐœ

์ด ์ˆ˜์น˜๋ฅผ ์ธก์ •ํ•˜๋Š” ๋ฐฉ๋ฒ•

What you can do

  • ๐ŸŽ€ Native: Utilizes the loading="lazy" attribute
  • ๐ŸŽ›๏ธ Framework-agnostic: Works with any framework or no framework at all
  • ๐ŸŒŠ BlurHash & ThumbHash support: SSR & client-side BlurHash and ThumbHash decoding
  • โšก Core Web Vitals-aware: Eager-priority path for above-the-fold images, dev-mode LCP warning

์ธก์ •๋œ ์Šคํƒ€ ์ฆ๊ฐ€

in 24h
0
in 7 days
+2
in 15 days
+2
in 1 month
๊ธฐ๋ก ์ˆ˜์ง‘ ์ค‘

์„œ๋กœ ๊ฒน์น˜๋Š” ๊ธฐ๊ฐ„์˜ ์ˆœ์ฆ๊ฐ€๋Ÿ‰์ด๋ฉฐ ์ผ๋ณ„ ํ•ฉ๊ณ„๊ฐ€ ์•„๋‹™๋‹ˆ๋‹ค. ์ธก์ •๊ฐ’์ด ์—†์œผ๋ฉด ๋น„์›Œ ๋‘ก๋‹ˆ๋‹ค. ์Šคํƒ€๋Š” ๊ด€์‹ฌ๋„๋ฅผ ๋‚˜ํƒ€๋‚ด๋ฉฐ ํ’ˆ์งˆ์„ ๋ณด์žฅํ•˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค.

README.md

Original

unlazy library

unlazy

npm version bundle

Native image lazy loading for vanilla JS, Vue, React, Svelte, Solid and Nuxt. Built around the loading="lazy" attribute, with BlurHash / ThumbHash placeholders, a dedicated above-the-fold priority path, and a dev-mode LCP warning so you never ship a lazy-loaded hero image by accident.

Features

  • ๐ŸŽ€ Native: Utilizes the loading="lazy" attribute
  • ๐ŸŽ›๏ธ Framework-agnostic: Works with any framework or no framework at all
  • ๐ŸŒŠ BlurHash & ThumbHash support: SSR & client-side BlurHash and ThumbHash decoding
  • โšก Core Web Vitals-aware: Eager-priority path for above-the-fold images, dev-mode LCP warning
  • ๐Ÿช„ Sizing: Automatically calculates the sizes attribute
  • ๐Ÿ” SEO-friendly: Detects search engine bots and preloads all images
  • ๐ŸŽŸ <picture>: Art direction and format selection with multiple sources
  • ๐ŸŽ Auto-initialize: Usable without a build step

Installation

๐Ÿ“– Read the documentation

# pnpm
pnpm add unlazy

# npm
npm i unlazy

For a framework, install its integration instead:

Basic Usage

Mark an image with loading="lazy" and put its source into data-src or data-srcset:

<img loading="lazy" data-src="image.jpg" width="640" height="360" alt="Descriptive text" />

Then import the lazyLoad function and call it without arguments to process all matching images:

import { lazyLoad } from 'unlazy'

// Processes every image with a `data-src` or `data-srcset`
lazyLoad()

For above-the-fold images (your hero / LCP image), use loading="eager". unlazy swaps the real source immediately and applies fetchpriority="high" for you:

<img loading="eager" data-src="hero.jpg" width="1600" height="900" alt="Sunset" />

To target specific images, pass a CSS selector, a DOM element, a list of DOM elements, or an array of DOM elements to lazyLoad.

๐Ÿ’ป Development

  1. Clone this repository
  2. Enable Corepack using corepack enable
  3. Install dependencies using pnpm install
  4. Run pnpm run dev:prepare
  5. Start a development server using pnpm run dev inside one of the framework packages, such as packages/vue

License

MIT License ยฉ 2023-PRESENT Johann Schopplich

๊ด€๋ จ ํ”„๋กœ์ ํŠธ ์‚ดํŽด๋ณด๊ธฐ

๋ถˆ๋Ÿฌ์˜ค๋Š” ์ค‘โ€ฆ