1. bianco.images-loader
Modern images loader helpers written in es2015 using generators and promises
bianco.images-loader
Package: bianco.images-loader
Created by: biancojs
Last modified: Mon, 13 Jun 2022 04:35:18 GMT
Version: 1.2.0
License: MIT
Downloads: 790
Repository: https://github.com/biancojs/images-loader

Install

npm install bianco.images-loader
yarn add bianco.images-loader

bianco.images-loader

Build Status
NPM version
NPM downloads
MIT License

Modern images loader helpers written in es2015 using promises

Usage

Load a single image

 import { loadImage } from 'bianco.images-loader'

loadImage('path/to/the/image.jpg').then(img => document.body.appendChild(img))

Or also DOM nodes:

 import $ from 'bianco.query'
import { loadImage } from 'bianco.images-loader'

loadImage($('img.cool'))
  .then(img => img.classList.add('loaded'))
  .catch(function(error) {
    // there was an error loading the image
  })

Load a multiple images

 import { loadImages } from 'bianco.images-loader'

loadImages([
    'path/to/the/image1.jpg',
    'path/to/the/image2.jpg'
  ])
  .then(imgs => imgs.forEach(i => document.body.appendChild(i)))
  .catch(error => {
    // there was an error loading one of images
  })

Or also...

 import $ from 'bianco.query'
import { loadImages } from 'bianco.images-loader'

loadImages($('img', '.main-content'))
  .then(imgs => imgs.forEach(i => i.classList.add('loaded')))
  .catch(error => {
    // there was an error loading one of images
  })

API

Table of Contents

loadImage

Preload any image

Parameters

Returns Promise a promise that will be resolved when the image will be completely loaded

loadImages

Load in parallel a collection of images

Parameters

Returns Promise a promise that will be resolved when all the images will be loaded

RELATED POST

10 Must-Know Windows Shortcuts That Will Save You Time

10 Must-Know Windows Shortcuts That Will Save You Time

Arrays vs Linked Lists: Which is Better for Memory Management in Data Structures?

Arrays vs Linked Lists: Which is Better for Memory Management in Data Structures?

Navigating AWS Networking: Essential Hacks for Smooth Operation

Navigating AWS Networking: Essential Hacks for Smooth Operation

Achieving Stunning Visuals with Unity's Global Illumination

Achieving Stunning Visuals with Unity's Global Illumination

Nim's Hidden Gems: Lesser-known Features for Writing Efficient Code

Nim's Hidden Gems: Lesser-known Features for Writing Efficient Code