
Security News
The Next Open Source Security Race: Triage at Machine Speed
Claude Opus 4.6 has uncovered more than 500 open source vulnerabilities, raising new considerations for disclosure, triage, and patching at scale.
A tiny (350B) library to detect when images have loaded
This module exposes three module definitions:
dist/onloaded.es.jsdist/onloaded.jsdist/onloaded.min.jsIf using the UMD bundle, the library is exposed as onloaded globally.
$ npm install --save onloaded
const onloaded = require('onloaded');
// passing a selector to `elem`
onloaded('#container > img', {
onLoad(img) {
img.className += ' loaded';
},
onError(img) {
img.className += ' failed';
},
onProgress(val) {
console.log(`I am ${ val * 100 }% complete!`);
},
onComplete(val, stats) {
// val is always 1 ~~> 100%
console.log('This callback always runs!');
console.log(` ${stats.loaded} loaded`);
console.log(` ${stats.failed} failed`);
console.log(` ${stats.total} total`);
}
});
Note: Visit
elemfor other possibilities!
Type: String|Node|NodeList
You have several options here:
Pass a selector string to img element(s);
onloaded('.container img', { ... });
Pass a reference to a specific <img /> DOM Node;
var img = document.querySelector('.container img');
onloaded(img, { ... });
Pass a reference to a multiple <img /> DOM Nodes;
var imgs = document.querySelectorAll('.container img');
onloaded(imgs, { ... });
Pass a reference to a container DOM Node that contains <img /> elements;
var parent = document.querySelector('.container');
onloaded(parent, { ... });
Type: Function
Callback whenever an image source failed to load. Receives the <img /> DOM node;
Type: Function
Callback whenever an image source sucessfully loads. Receives the <img /> DOM node;
Type: Function
Callback whenever an image's network request has completed, regardless of success or failure.
Receives the current "progress" of completed requests as a decimal.
Also receives a stats object with loaded, failed, and total keys.
Type: Function
Callback when all network requests have completed, regardless of success or failure.
Receives the "progress" as its first parameter. This will always equal 1.
Also receives a stats object with loaded, failed, and total keys.
MIT © Luke Edwards
FAQs
A tiny (350B) library to detect when images have loaded.
We found that onloaded 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
Claude Opus 4.6 has uncovered more than 500 open source vulnerabilities, raising new considerations for disclosure, triage, and patching at scale.

Research
/Security News
Malicious dYdX client packages were published to npm and PyPI after a maintainer compromise, enabling wallet credential theft and remote code execution.

Security News
gem.coop is testing registry-level dependency cooldowns to limit exposure during the brief window when malicious gems are most likely to spread.