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.
image-promise
Advanced tools
Load an image and return a promise in the browser, in 0.4KB, no dependencies
npm install --save image-promise
import loadImage from 'image-promise';
If you don't use node/babel, include this:
<script src="dist/image-promise.browser.js"></script>
It uses the ES2015 window.Promise
, so if you need to support older browsers you need a polyfill.
You can load a single image from its URL:
loadImage('img.jpg').then(function (img) {
console.log('Image loaded!', img);
}).catch(function () {
console.error('Image failed to load :(');
});
image-promise
also caches the generated <img>
tags so successive calls with the same exact src
string will return the same <img>
tag and be resolve at the same time as the first one.
Because are <img>
are cached internally, if you want to uncache and unload them from memory, call the unload
method on the same src
:
loadImage.unload('img.jpg');
None! But you might need to polyfill window.Promise
MIT © Federico Brigante
FAQs
Load one or more images, return a promise. Only 0.4KB, for the browser, no dependencies.
The npm package image-promise receives a total of 2,742 weekly downloads. As such, image-promise popularity was classified as popular.
We found that image-promise demonstrated a healthy version release cadence and project activity because the last version was released less than 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.