This is a simple jQuery plugin for loading images.
Install
npm install jquery-image-loader --save
Classic
Load the jQuery and this plugin.
ECMAScript 6
This plugin is written in ECMAScript 6, so you can just simply import the source file.
// Setup plugin;
Usage
Assume you have the following markup.
You can load IMG_1.jpg
and IMG_2.jpg
by :
;
If you want to load image by URL, use the ImageLoader
instance instead.
var imageLoader = $ // Create a new ImageLoader instance $images = imgs = 'https://static.pexels.com/photos/6151/animal-cute-fur-white.jpg' // Image url $images0 // <img> element $images1 // Element has a `background-image` ; imageLoader // Start load images ;