Socket
Socket
Sign inDemoInstall

imagesloaded

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

imagesloaded

JavaScript is all like _You images done yet or what?_


Version published
Weekly downloads
254K
increased by6.5%
Maintainers
1
Weekly downloads
 
Created

What is imagesloaded?

The imagesloaded npm package is a JavaScript library that detects when images have been loaded in a webpage. It is useful for ensuring that all images are fully loaded before performing certain actions, such as initializing a gallery or applying layout adjustments.

What are imagesloaded's main functionalities?

Basic Usage

This feature allows you to detect when all images within a specified container have been loaded. The callback function is executed once all images are fully loaded.

const imagesLoaded = require('imagesloaded');

imagesLoaded('#container', function() {
  console.log('All images are loaded');
});

Handling Individual Image Load Events

This feature allows you to handle events for each individual image as it loads. You can use the 'progress' event to check the status of each image and perform actions accordingly.

const imagesLoaded = require('imagesloaded');

imagesLoaded('#container').on('progress', function(instance, image) {
  if (image.isLoaded) {
    console.log('Image loaded:', image.img.src);
  } else {
    console.log('Image failed to load:', image.img.src);
  }
});

Using Promises

This feature allows you to use promises with imagesloaded. You can use the 'then' method to execute code when all images are loaded and the 'catch' method to handle any errors if one or more images fail to load.

const imagesLoaded = require('imagesloaded');

imagesLoaded('#container').then(function(instance) {
  console.log('All images are loaded');
}).catch(function(instance) {
  console.log('One or more images failed to load');
});

Other packages similar to imagesloaded

Keywords

FAQs

Package last updated on 04 May 2017

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc