Gathering detailed insights and metrics for @unpic/core
Gathering detailed insights and metrics for @unpic/core
Gathering detailed insights and metrics for @unpic/core
Gathering detailed insights and metrics for @unpic/core
npm install @unpic/core
97.9
Supply Chain
72
Quality
88.6
Maintenance
100
Vulnerability
100
License
astro: v0.0.47
Published on 17 Sept 2024
react: v0.1.14
Published on 28 Apr 2024
lit: v0.0.30
Published on 19 Mar 2024
angular: v0.0.39
Published on 19 Mar 2024
webc: v0.0.43
Published on 19 Mar 2024
qwik: v0.0.46
Published on 19 Mar 2024
Module System
Min. Node Version
Typescript Support
Node Version
NPM Version
1,400 Stars
606 Commits
52 Forks
7 Watching
13 Branches
25 Contributors
Updated on 28 Nov 2024
Minified
Minified + Gzipped
TypeScript (90.81%)
Astro (2.91%)
Svelte (2.34%)
Vue (1.83%)
JavaScript (1.76%)
HTML (0.34%)
Cumulative downloads
Total Downloads
Last day
-9%
4,874
Compared to previous day
Last week
-7.5%
23,509
Compared to previous week
Last month
12.8%
106,992
Compared to previous month
Last year
-21.2%
1,305,696
Compared to previous year
A cross-framework component for responsive, high-performance images using image CDNs
React • Vue • SolidJS • Svelte • Astro
Preact • Qwik • WebC • Angular • Lit
<img>
tag! No extra elements, no runtime JavaScript. Easy to style.
No legacy hacks or workarounds.@unpic/placeholder
for more
options.For details of usage, see the documentation.
While it's easy to use an <img>
tag for images, if you want to follow best
practices and deliver the most performant image to your users then it can take a
lot of work. Some frontend frameworks will automate this for you, but they often
rely on slow pre-rendering of images, or on running image optimizers on your own
site. They also generate complex HTML with wrappers and spacer elements that
make images hard to style.
Most images on modern websites are hosted on a CDN or CMS that can resize images on the fly and deliver them at the edge. Despite this, most web frameworks will still download and resize the image at build time or on your server, rather than using the CDN, or just uses a single source image rather than handling multiple resolutions.
This library works with any frontend framework or none, and uses your existing image CDN or CMS, with no additional configuration.
For more details, see this post.
This library uses unpic to detect the image CDN, and then uses the CDN's URL API
to resize and format images. It then generates the correct srcset
and sizes
attributes for the image. It uses new features built into modern browsers to
handle lazy loading, fetch priority and decoding. It also uses pure CSS to
handle responsive resizing of images, preserving aspect ratio and avoiding
layout shift. Unlike most other image components, it does not use any
client-side JavaScript by default, and generates just a single <img>
tag
without any wrapper divs or padding elements.
1<Image 2 src="https://cdn.shopify.com/static/sample-images/bath_grande_crop_center.jpeg" 3 layout="constrained" 4 width={800} 5 height={600} 6 alt="Shopify" 7/>
...into this:
1<img 2 alt="Shopify" 3 loading="lazy" 4 decoding="async" 5 sizes="(min-width: 800px) 800px, 100vw" 6 srcset=" 7 https://cdn.shopify.com/static/sample-images/bath.jpeg?crop=center&width=1600&height=2133 1600w, 8 https://cdn.shopify.com/static/sample-images/bath.jpeg?crop=center&width=1280&height=1707 1280w, 9 https://cdn.shopify.com/static/sample-images/bath.jpeg?crop=center&width=1080&height=1440 1080w, 10 https://cdn.shopify.com/static/sample-images/bath.jpeg?crop=center&width=960&height=1280 960w, 11 https://cdn.shopify.com/static/sample-images/bath.jpeg?crop=center&width=828&height=1104 828w, 12 https://cdn.shopify.com/static/sample-images/bath.jpeg?crop=center&width=800&height=1067 800w, 13 https://cdn.shopify.com/static/sample-images/bath.jpeg?crop=center&width=750&height=1000 750w, 14 https://cdn.shopify.com/static/sample-images/bath.jpeg?crop=center&width=640&height=853 640w 15 " 16 src="https://cdn.shopify.com/static/sample-images/bath.jpeg?width=800&height=600&crop=center" 17 style=" 18 object-fit: cover; 19 max-width: 800px; 20 max-height: 600px; 21 aspect-ratio: 1.33333 / 1; 22 width: 100%; 23 " 24/>
You can use any image CDN supported by unpic lib, including:
Published under the MIT licence. © Matt Kane 2023.
No vulnerabilities found.
No security vulnerabilities found.