Security News
Node.js EOL Versions CVE Dubbed the "Worst CVE of the Year" by Security Experts
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
@lipp/img-min
Advanced tools
A web component for minimal, responsive and lazy images for webp and jpeg
<img-min>
<img-min>
is a zero dependency vanilla web-component / custom element which can help you and your users to save a lot of bandwidth. It lazy loads minimal responsive images with auto-thumbnail and cool dissolve effect inspired by Medium.
For more info and a live demo checkout img-min.now.sh or start playing with the codepen.io.
Add <script>
at the top of your page:
<script src="https://unpkg.com/@lipp/img-min" ></script>
Or serve / inline yourself:
npm i @lipp/img-min
...
The following properties / attributes are supported:
Property | Decription |
---|---|
src (required) | The url to the highres version of your image |
quality | The quality to use for resizing (0 - 100), default 50 |
alt | The familiar img alt attribute |
Property | Decription |
---|---|
--aspect-ratio | The aspect ratio (width/height) to use, e.g. 16/9 |
To make lazy loading work optimal, the <img-min>
should have a (responsive)
height. You can either do it yourself, or use the CSS custom property
--aspect-ratio
for your <img-min>
tags. You can use CSS, inline style or
JS to set the respective value. You can use the original image's width/height as
--aspect-ratio
.
The <img-min>
uses a free CDN backed resizer. You can use your own by providing a window.ImgMin.getCDNUrl
function:
window.ImgMin.getCDNUrl = ({
width, // width on screen
height, // height on screen
url, // original high-res image url (src attr)
quality, // quality setting for the respective image
format // "jpeg" or "webp"
}) => {
// for the cloudimg.io service, this makes sense
return `https://<YOUR-TOKEN>.cloudimg.io/width/${Math.floor(
(60 / quality) * width
)}/n/${url}`
}
<div style="width: 100%;">
<img-min
src="https://images.unsplash.com/photo-1519681393784-d120267933ba?ixlib=rb-0.3.5&ixid=eyJhcHBfaWQiOjEyMDd9&s=9e2448175103d36c873e2511d112d339&auto=format&fit=crop&w=1350&q=80"
quality="80"
alt="Hero image"
style="--aspect-ratio: 1189/792;"
></img-min>
</div>
FAQs
A web component for minimal, responsive and lazy images for webp and jpeg
We found that @lipp/img-min demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
Security News
cURL and Go security teams are publicly rejecting CVSS as flawed for assessing vulnerabilities and are calling for more accurate, context-aware approaches.
Security News
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.