Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

dll.js

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

dll.js - npm Package Compare versions

Comparing version 1.5.4 to 1.5.5

40

dist/dll.esm.js
/*!
* DLL.js v1.5.4 (https://thednp.github.io/dll.js/)
* DLL.js v1.5.5 (https://thednp.github.io/dll.js/)
* Copyright 2020 © thednp
* Licensed under MIT (https://github.com/thednp/dll.js/blob/master/LICENSE)
*/
function queryElement (selector, parent) {
function queryElement(selector, parent) {
var lookUp = parent && parent instanceof Element ? parent : document;

@@ -11,28 +11,9 @@ return selector instanceof Element ? selector : lookUp.querySelector(selector);

function tryWrapper (fn,origin){
function tryWrapper(fn,origin){
try{ fn(); }
catch(e){
console.error((origin + ": " + e));
console.error((origin + " " + e));
}
}
function on (element, event, handler, options) {
options = options || false;
element.addEventListener(event, handler, options);
}
function off (element, event, handler, options) {
options = options || false;
element.removeEventListener(event, handler, options);
}
function one (element, event, handler, options) {
on(element, event, function handlerWrapper(e){
if (e.target === element) {
handler(e);
off(element, event, handlerWrapper, options);
}
}, options);
}
function loadMedia(mediaElement, imageCallback) {

@@ -45,3 +26,3 @@ var isVideo = mediaElement.tagName === 'SOURCE',

src = mediaElement.getAttribute('data-src');
one(loadTarget,loadEvent,function (){
loadTarget.addEventListener(loadEvent, function loadWrapper(){
if (mediaElement.tagName === 'IMG') { mediaElement.src=src; }

@@ -55,2 +36,3 @@ else if (mediaElement.tagName === 'SOURCE') {

imageCallback && imageCallback();
loadTarget.removeEventListener(loadEvent, loadWrapper);
});

@@ -97,8 +79,12 @@ mediaObject.src = src;

function initComponent() {
var DLLImages = Array.from(document.querySelectorAll('[data-src]'));
function initComponent(lookup) {
lookup = lookup ? lookup : document;
var DLLImages = Array.from(lookup.querySelectorAll('[data-src]'));
DLLImages.map(function (x){ return new DLL(x); });
}
document.body ? initComponent() : one(document, 'DOMContentLoaded', initComponent);
document.body ? initComponent() : document.addEventListener( 'DOMContentLoaded', function initWrapper(){
initComponent();
document.removeEventListener( 'DOMContentLoaded', initWrapper );
});
export default DLL;

@@ -1,2 +0,2 @@

// DLL.js v1.5.4 | 2020 © thednp | MIT-License
function t(t,e,n,r){!function(t,e,n,r){r=r||!1,t.addEventListener(e,n,r)}(t,e,(function a(c){c.target===t&&(n(c),function(t,e,n,r){r=r||!1,t.removeEventListener(e,n,r)}(t,e,a,r))}),r)}function e(e,n){var r="SOURCE"===e.tagName,a=r?"loadstart":"load",c=r?document.createElement("VIDEO"):0,o=r?document.createElement("SOURCE"):new Image,u=r?c:o,l=e.getAttribute("data-src");t(u,a,(function(){"IMG"===e.tagName?e.src=l:"SOURCE"===e.tagName?(e.src=l,e.parentNode.load()):e.style.backgroundImage='url("'+l+'")',e.removeAttribute("data-src"),n&&n()})),o.src=l,c&&c.appendChild(o)}function n(t,n){!function(t,e){try{t()}catch(t){console.error(e+": "+t)}}((function(){var r,a,c;r=t,c=a&&a instanceof Element?a:document,t=r instanceof Element?r:c.querySelector(r),n="function"==typeof n?n:null;var o=function(t){var e,n=[],r=t.querySelectorAll("[data-src]"),a=t?t.getAttribute("data-src"):null;return a&&!r?e=[t]:!a&&r?e=r:a&&r?(e=r,n.unshift(t)):a||r||(e=document.querySelectorAll("[data-src]")),Array.from(e).map((function(t){return n.push(t)})),n}(t);((t?t.getAttribute("data-src"):null)||null!==t.querySelector("[data-src]"))&&o.map((function(t,r){r===o.length-1&&n?e(t,n):e(t)}))}),"DLL.js:")}function r(){Array.from(document.querySelectorAll("[data-src]")).map((function(t){return new n(t)}))}document.body?r():t(document,"DOMContentLoaded",r);export default n;
// DLL.js v1.5.5 | 2020 © thednp | MIT-License
function e(e,t){var n="SOURCE"===e.tagName,r=n?"loadstart":"load",a=n?document.createElement("VIDEO"):0,o=n?document.createElement("SOURCE"):new Image,c=n?a:o,u=e.getAttribute("data-src");c.addEventListener(r,(function n(){"IMG"===e.tagName?e.src=u:"SOURCE"===e.tagName?(e.src=u,e.parentNode.load()):e.style.backgroundImage='url("'+u+'")',e.removeAttribute("data-src"),t&&t(),c.removeEventListener(r,n)})),o.src=u,a&&a.appendChild(o)}function t(t,n){!function(e,t){try{e()}catch(e){console.error(t+" "+e)}}((function(){var r,a,o;r=t,o=a&&a instanceof Element?a:document,t=r instanceof Element?r:o.querySelector(r),n="function"==typeof n?n:null;var c=function(e){var t,n=[],r=e.querySelectorAll("[data-src]"),a=e?e.getAttribute("data-src"):null;return a&&!r?t=[e]:!a&&r?t=r:a&&r?(t=r,n.unshift(e)):a||r||(t=document.querySelectorAll("[data-src]")),Array.from(t).map((function(e){return n.push(e)})),n}(t);((t?t.getAttribute("data-src"):null)||null!==t.querySelector("[data-src]"))&&c.map((function(t,r){r===c.length-1&&n?e(t,n):e(t)}))}),"DLL.js:")}function n(e){e=e||document,Array.from(e.querySelectorAll("[data-src]")).map((function(e){return new t(e)}))}document.body?n():document.addEventListener("DOMContentLoaded",(function e(){n(),document.removeEventListener("DOMContentLoaded",e)}));export default t;
/*!
* DLL.js v1.5.4 (https://thednp.github.io/dll.js/)
* DLL.js v1.5.5 (https://thednp.github.io/dll.js/)
* Copyright 2020 © thednp

@@ -12,3 +12,3 @@ * Licensed under MIT (https://github.com/thednp/dll.js/blob/master/LICENSE)

function queryElement (selector, parent) {
function queryElement(selector, parent) {
var lookUp = parent && parent instanceof Element ? parent : document;

@@ -18,28 +18,9 @@ return selector instanceof Element ? selector : lookUp.querySelector(selector);

function tryWrapper (fn,origin){
function tryWrapper(fn,origin){
try{ fn(); }
catch(e){
console.error((origin + ": " + e));
console.error((origin + " " + e));
}
}
function on (element, event, handler, options) {
options = options || false;
element.addEventListener(event, handler, options);
}
function off (element, event, handler, options) {
options = options || false;
element.removeEventListener(event, handler, options);
}
function one (element, event, handler, options) {
on(element, event, function handlerWrapper(e){
if (e.target === element) {
handler(e);
off(element, event, handlerWrapper, options);
}
}, options);
}
function loadMedia(mediaElement, imageCallback) {

@@ -52,3 +33,3 @@ var isVideo = mediaElement.tagName === 'SOURCE',

src = mediaElement.getAttribute('data-src');
one(loadTarget,loadEvent,function (){
loadTarget.addEventListener(loadEvent, function loadWrapper(){
if (mediaElement.tagName === 'IMG') { mediaElement.src=src; }

@@ -62,2 +43,3 @@ else if (mediaElement.tagName === 'SOURCE') {

imageCallback && imageCallback();
loadTarget.removeEventListener(loadEvent, loadWrapper);
});

@@ -104,7 +86,11 @@ mediaObject.src = src;

function initComponent() {
var DLLImages = Array.from(document.querySelectorAll('[data-src]'));
function initComponent(lookup) {
lookup = lookup ? lookup : document;
var DLLImages = Array.from(lookup.querySelectorAll('[data-src]'));
DLLImages.map(function (x){ return new DLL(x); });
}
document.body ? initComponent() : one(document, 'DOMContentLoaded', initComponent);
document.body ? initComponent() : document.addEventListener( 'DOMContentLoaded', function initWrapper(){
initComponent();
document.removeEventListener( 'DOMContentLoaded', initWrapper );
});

@@ -111,0 +97,0 @@ return DLL;

@@ -1,2 +0,2 @@

// DLL.js v1.5.4 | 2020 © thednp | MIT-License
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t=t||self).dll=e()}(this,(function(){"use strict";function t(t,e,n,r){!function(t,e,n,r){r=r||!1,t.addEventListener(e,n,r)}(t,e,(function o(c){c.target===t&&(n(c),function(t,e,n,r){r=r||!1,t.removeEventListener(e,n,r)}(t,e,o,r))}),r)}function e(e,n){var r="SOURCE"===e.tagName,o=r?"loadstart":"load",c=r?document.createElement("VIDEO"):0,u=r?document.createElement("SOURCE"):new Image,a=r?c:u,d=e.getAttribute("data-src");t(a,o,(function(){"IMG"===e.tagName?e.src=d:"SOURCE"===e.tagName?(e.src=d,e.parentNode.load()):e.style.backgroundImage='url("'+d+'")',e.removeAttribute("data-src"),n&&n()})),u.src=d,c&&c.appendChild(u)}function n(t,n){!function(t,e){try{t()}catch(t){console.error(e+": "+t)}}((function(){var r,o,c;r=t,c=o&&o instanceof Element?o:document,t=r instanceof Element?r:c.querySelector(r),n="function"==typeof n?n:null;var u=function(t){var e,n=[],r=t.querySelectorAll("[data-src]"),o=t?t.getAttribute("data-src"):null;return o&&!r?e=[t]:!o&&r?e=r:o&&r?(e=r,n.unshift(t)):o||r||(e=document.querySelectorAll("[data-src]")),Array.from(e).map((function(t){return n.push(t)})),n}(t);((t?t.getAttribute("data-src"):null)||null!==t.querySelector("[data-src]"))&&u.map((function(t,r){r===u.length-1&&n?e(t,n):e(t)}))}),"DLL.js:")}function r(){Array.from(document.querySelectorAll("[data-src]")).map((function(t){return new n(t)}))}return document.body?r():t(document,"DOMContentLoaded",r),n}));
// DLL.js v1.5.5 | 2020 © thednp | MIT-License
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e=e||self).dll=t()}(this,(function(){"use strict";function e(e,t){var n="SOURCE"===e.tagName,r=n?"loadstart":"load",o=n?document.createElement("VIDEO"):0,a=n?document.createElement("SOURCE"):new Image,c=n?o:a,u=e.getAttribute("data-src");c.addEventListener(r,(function n(){"IMG"===e.tagName?e.src=u:"SOURCE"===e.tagName?(e.src=u,e.parentNode.load()):e.style.backgroundImage='url("'+u+'")',e.removeAttribute("data-src"),t&&t(),c.removeEventListener(r,n)})),a.src=u,o&&o.appendChild(a)}function t(t,n){!function(e,t){try{e()}catch(e){console.error(t+" "+e)}}((function(){var r,o,a;r=t,a=o&&o instanceof Element?o:document,t=r instanceof Element?r:a.querySelector(r),n="function"==typeof n?n:null;var c=function(e){var t,n=[],r=e.querySelectorAll("[data-src]"),o=e?e.getAttribute("data-src"):null;return o&&!r?t=[e]:!o&&r?t=r:o&&r?(t=r,n.unshift(e)):o||r||(t=document.querySelectorAll("[data-src]")),Array.from(t).map((function(e){return n.push(e)})),n}(t);((t?t.getAttribute("data-src"):null)||null!==t.querySelector("[data-src]"))&&c.map((function(t,r){r===c.length-1&&n?e(t,n):e(t)}))}),"DLL.js:")}function n(e){e=e||document,Array.from(e.querySelectorAll("[data-src]")).map((function(e){return new t(e)}))}return document.body?n():document.addEventListener("DOMContentLoaded",(function e(){n(),document.removeEventListener("DOMContentLoaded",e)})),t}));
{
"name": "dll.js",
"version": "1.5.4",
"version": "1.5.5",
"description": "Double Lazy Load for Images, Videos and Background Images.",
"main": "dist/dll.min.js",
"module": "dist/dll-esm.js",
"module": "dist/dll.esm.js",
"jsnext": "src/dll.js",
"files" :[
"files": [
"dist/*.{js,map}",

@@ -40,7 +40,7 @@ "src/*.{js,map}"

"dependencies": {
"shorter-js": "^0.0.5"
"shorter-js": "^0.1.0"
},
"devDependencies": {
"@rollup/plugin-buble": "^0.21.3",
"@rollup/plugin-json": "^4.0.3",
"@rollup/plugin-json": "^4.1.0",
"@rollup/plugin-node-resolve": "^7.1.0",

@@ -47,0 +47,0 @@ "npm-run-all": "^4.1.5",

@@ -1,3 +0,3 @@

import { queryElement } from 'shorter-js/src/misc/queryElement.js';
import { tryWrapper } from 'shorter-js/src/misc/tryWrapper.js';
import queryElement from 'shorter-js/src/misc/queryElement.js';
import tryWrapper from 'shorter-js/src/misc/tryWrapper.js';
import loadMedia from './loadMedia.js'

@@ -4,0 +4,0 @@ import getMediaElements from './getMediaElements.js'

import DLL from './dll.js'
import {one} from 'shorter-js/src/event/one.js'
// DATA API
function initComponent() {
let DLLImages = Array.from(document.querySelectorAll('[data-src]'));
function initComponent(lookup) {
lookup = lookup ? lookup : document;
let DLLImages = Array.from(lookup.querySelectorAll('[data-src]'));
DLLImages.map(x=>new DLL(x))
}
// initialize when loaded
document.body ? initComponent() : one(document, 'DOMContentLoaded', initComponent);
document.body ? initComponent() : document.addEventListener( 'DOMContentLoaded', function initWrapper(){
initComponent()
document.removeEventListener( 'DOMContentLoaded', initWrapper )
});

@@ -1,5 +0,2 @@

import { one } from 'shorter-js/src/event/one.js';
// load
export default function loadMedia(mediaElement, imageCallback) {
export default function(mediaElement, imageCallback) {
var isVideo = mediaElement.tagName === 'SOURCE',

@@ -12,3 +9,3 @@ loadEvent = isVideo ? 'loadstart' : 'load',

one(loadTarget,loadEvent,()=>{
loadTarget.addEventListener(loadEvent, function loadWrapper(){
if (mediaElement.tagName === 'IMG') { mediaElement.src=src; } // 'IMG'

@@ -22,2 +19,3 @@ else if (mediaElement.tagName === 'SOURCE') { // 'VIDEO' 'SOURCE'

imageCallback && imageCallback();
loadTarget.removeEventListener(loadEvent, loadWrapper)
})

@@ -24,0 +22,0 @@ mediaObject.src = src;

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