Comparing version 1.0.2 to 1.0.4
@@ -1,2 +0,2 @@ | ||
/*! lozad.js - v1.0.2 - 2017-09-10 | ||
/*! lozad.js - v1.0.4 - 2017-09-22 | ||
* https://github.com/ApoorvSaxena/lozad.js | ||
@@ -62,18 +62,14 @@ * Copyright (c) 2017 Apoorv Saxena; Licensed MIT */ | ||
observe: function observe() { | ||
var elements = [].filter.call(document.querySelectorAll(selector), function (element) { | ||
return !isLoaded(element); | ||
}); | ||
if (!observer) { | ||
elements.forEach(function (element) { | ||
load(element); | ||
markAsLoaded(element); | ||
}); | ||
return; | ||
var elements = document.querySelectorAll(selector); | ||
for (var i = 0; i < elements.length; i++) { | ||
if (isLoaded(elements[i])) { | ||
continue; | ||
} | ||
if (observer) { | ||
observer.observe(elements[i]); | ||
continue; | ||
} | ||
load(elements[i]); | ||
markAsLoaded(elements[i]); | ||
} | ||
elements.forEach(function (element) { | ||
observer.observe(element); | ||
}); | ||
} | ||
@@ -80,0 +76,0 @@ }; |
@@ -1,4 +0,4 @@ | ||
/*! lozad.js - v1.0.2 - 2017-09-10 | ||
/*! lozad.js - v1.0.4 - 2017-09-22 | ||
* https://github.com/ApoorvSaxena/lozad.js | ||
* Copyright (c) 2017 Apoorv Saxena; Licensed MIT */ | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):t.lozad=e()}(this,function(){"use strict";function t(t){t.dataset.loaded=!0}var e=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(t[o]=n[o])}return t},n={rootMargin:"0px",threshold:0,load:function(t){t.src=t.dataset.src}},o=function(t){return"true"===t.dataset.loaded},r=function(e){return function(n,o){n.forEach(function(n){n.intersectionRatio>0&&(o.unobserve(n.target),e(n.target),t(n.target))})}};return function(){var i=arguments.length>0&&void 0!==arguments[0]?arguments[0]:".lozad",a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},c=e({},n,a),u=c.rootMargin,f=c.threshold,d=c.load,s=void 0;return window.IntersectionObserver&&(s=new IntersectionObserver(r(d),{rootMargin:u,threshold:f})),{observe:function(){var e=[].filter.call(document.querySelectorAll(i),function(t){return!o(t)});s?e.forEach(function(t){s.observe(t)}):e.forEach(function(e){d(e),t(e)})}}}}); | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):e.lozad=t()}(this,function(){"use strict";function e(e){e.dataset.loaded=!0}var t=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var o=arguments[t];for(var n in o)Object.prototype.hasOwnProperty.call(o,n)&&(e[n]=o[n])}return e},o={rootMargin:"0px",threshold:0,load:function(e){e.src=e.dataset.src}},n=function(e){return"true"===e.dataset.loaded},r=function(t){return function(o,n){o.forEach(function(o){o.intersectionRatio>0&&(n.unobserve(o.target),t(o.target),e(o.target))})}};return function(){var i=arguments.length>0&&void 0!==arguments[0]?arguments[0]:".lozad",a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},d=t({},o,a),c=d.rootMargin,u=d.threshold,s=d.load,f=void 0;return window.IntersectionObserver&&(f=new IntersectionObserver(r(s),{rootMargin:c,threshold:u})),{observe:function(){for(var t=document.querySelectorAll(i),o=0;o<t.length;o++)n(t[o])||(f?f.observe(t[o]):(s(t[o]),e(t[o])))}}}}); |
@@ -5,7 +5,9 @@ { | ||
"description": "A light-weight JS library to lazy load any HTML element such as images, ads, videos etc.", | ||
"version": "1.0.2", | ||
"version": "1.0.4", | ||
"homepage": "https://github.com/ApoorvSaxena/lozad.js", | ||
"scripts": { | ||
"build": "node build.js", | ||
"prepublish": "npm run build", | ||
"prelint": "prettier --single-quote --no-semi --no-bracket-spacing --trailing-comma none --write \"lib/**/*.js\" --write build.js --write", | ||
"precommit": "npm run lint", | ||
"lint": "xo --fix src/*.js build.js" | ||
@@ -50,2 +52,3 @@ }, | ||
"babel-preset-stage-0": "^6.24.1", | ||
"husky": "^0.14.3", | ||
"prettier": "^1.6.1", | ||
@@ -52,0 +55,0 @@ "rollup": "^0.49.2", |
@@ -1,2 +0,2 @@ | ||
# Lozad.js [![npm version](https://badge.fury.io/js/lozad.svg)](https://badge.fury.io/js/lozad) | ||
# Lozad.js [![npm version](https://badge.fury.io/js/lozad.svg)](https://badge.fury.io/js/lozad) [![Build Status](https://travis-ci.org/ApoorvSaxena/lozad.js.svg?branch=master)](https://travis-ci.org/ApoorvSaxena/lozad.js) | ||
@@ -34,23 +34,27 @@ > Highly performant, light ~0.5kb and configurable lazy loader in pure JS with no dependencies for images, iframes and more, using IntersectionObserver API | ||
Get the library using one of the following ways: | ||
```sh | ||
# You can install lozad with npm | ||
$ npm install --save lozad | ||
1. **GitHub** | ||
# Alternatively you can use Yarn. | ||
$ yarn add lozad | ||
Full build | ||
# Another option is to use Bower. | ||
$ bower install lozad | ||
``` | ||
- [unminified] : https://raw.githubusercontent.com/ApoorvSaxena/lozad.js/master/dist/lozad.js | ||
- [minified] : https://raw.githubusercontent.com/ApoorvSaxena/lozad.js/master/dist/lozad.min.js | ||
Then with a module bundler like rollup or webpack, use as you would anything else: | ||
2. **Yarn** : `yarn add lozad` | ||
```javascript | ||
// using ES6 modules | ||
import lozad from 'lozad' | ||
3. **Bower** : `bower install lozad` | ||
// using CommonJS modules | ||
var lozad = require('lozad') | ||
``` | ||
3. **npm**: `npm install --save lozad` | ||
Or load via **CDN** and include in the `head` tag of your page. | ||
4. **CDN**: [https://cdn.jsdelivr.net/npm/lozad](https://cdn.jsdelivr.net/npm/lozad) | ||
Now include the library in the ``HEAD`` tag of your page: | ||
```html | ||
<script type="text/javascript" src="lozad.js"></script> | ||
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/lozad/dist/lozad.js"></script> | ||
``` | ||
@@ -60,6 +64,6 @@ or | ||
```html | ||
<script type="text/javascript" src="lozad.min.js"></script> | ||
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/lozad/dist/lozad.min.js"></script> | ||
``` | ||
**Note**: `lozad.js` supports AMD and commonJS module pattern out of the box. | ||
When loading from CDN, you can find the library on `window.lozad`. | ||
@@ -132,2 +136,2 @@ ## Usage | ||
[MIT](LICENSE) © [Apoorv Saxena](https://apoorv.pro) | ||
[MIT](LICENSE) © [Apoorv Saxena](https://apoorv.pro) |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
10890
135
0
11
74