pax_global_header00006660000000000000000000000064137727235100014521gustar00rootroot0000000000000052 comment=ba3dd45004c74adfcedb431b46c83a5fe8cd4f4a libjs-blazy-1.8.2+dfsg/000077500000000000000000000000001377272351000146725ustar00rootroot00000000000000libjs-blazy-1.8.2+dfsg/LICENSE000066400000000000000000000020771377272351000157050ustar00rootroot00000000000000The MIT License (MIT) Copyright (c) 2013-16 Bjørn Klinggaard Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. libjs-blazy-1.8.2+dfsg/README.md000066400000000000000000000257101377272351000161560ustar00rootroot00000000000000#hey, be lazy [![Downloads](https://img.shields.io/npm/dm/blazy.svg?style=flat)](https://www.npmjs.com/package/blazy) [![Latest Stable Version](https://img.shields.io/npm/v/blazy.svg?style=flat)](https://www.npmjs.com/package/blazy) [![License](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/dinbror/blazy/blob/master/LICENSE) bLazy is a lightweight script for lazy loading and multi-serving images, iframes, videos and more (less than 1.4KB minified and gzipped). It’s written in pure JavaScript why it doesn’t depend on 3rd-party libraries such as jQuery. It lets you lazy load and multi-serve your images so you can save bandwidth and server requests. The user will have faster load times and save data usage if he/she doesn't browse the whole page. **Table of Contents**
1. [Demo](https://github.com/dinbror/blazy#demo)
2. [Usage & API](https://github.com/dinbror/blazy#usage--api)
3. [Why be lazy?](https://github.com/dinbror/blazy#why-be-lazy)
4. [Changelog](https://github.com/dinbror/blazy#changelog)
5. [License](https://github.com/dinbror/blazy#license)
## DEMO ## [http://dinbror.dk/blazy/](http://dinbror.dk/blazy/?ref=github) More examples: [http://dinbror.dk/blazy/examples/](http://dinbror.dk/blazy/examples/?ref=github) Codepen playground: http://codepen.io/dinbror/pen/HzCAJ ## USAGE & API ## [http://dinbror.dk/blog/blazy/](http://dinbror.dk/blog/blazy/?ref=github) ### INSTALL You can install blazy.js with npm: ``` npm npm install blazy --save ``` or bower: ``` bower bower install blazy --save ``` ### CDN If you don't want to host the script yourself you can link to the latest minified file: `//cdn.jsdelivr.net/blazy/latest/blazy.min.js` on [jsDelivr](http://www.jsdelivr.com/#!blazy). Exchange `latest` with the specific version number if you want to lock it in. ## WHY BE LAZY? ## * bLazy is used on big sites with millions of monthly visitors so it has been tested out in the real world. * bLazy is written in pure JavaScript why it doesn’t depend on 3rd-party libraries such as jQuery. * bLazy is lightweight, less than 1.4KB and less than 1.25KB if you don't need IE7- support. * bLazy is very fast. It has focus on performance why it also auto-destroys when it's done lazy loading. * bLazy can lazy load all types of images including background images. * bLazy is future-proof. It supports srcset and the picture element. * bLazy can serve retina images on retina devices. * bLazy can lazy load everything with a src like iframes, HTML5 videos, scripts, unity games etc. * bLazy supports all browsers used today including legacy browsers like IE7 and 8. * bLazy supports all main module formats like AMD, CommonJS and globals. ## WISHLIST/NEW FEATURES REQUESTED BY YOU * Only preload "first frame" of progressive jpegs. * Add support for CSS background property; [image-set](https://cloudfour.com/examples/image-set/) ([caniuse](http://caniuse.com/#feat=css-image-set)). * Add a class when the lazyloading begins. * Option to keen load once on screen images have loaded. * Add option to disable success/error classes * Animate the container that contains the image you lazy load. You can do that today by adding/removing a class in the success callback. ## CHANGELOG ### v 1.8.2 (2016/10/25) ### * Added null check in public `load` function. * Bugfix: Fixed `this` issue defaulting to window when passing `revalidate` or `destroy` in setTimeout as reference [#73](https://github.com/dinbror/blazy/issues/73) and [#112](https://github.com/dinbror/blazy/pull/112). Thanks [PeteDuncanson](https://github.com/PeteDuncanson). * Bugfix: If parts of container is outside window use the viewport boundaries [#113](https://github.com/dinbror/blazy/issues/113) and [#114](https://github.com/dinbror/blazy/pull/114). Thanks [dbirkbeck](https://github.com/dbirkbeck). ### v 1.8.1 (2016/10/22) ### * Bugfix: Created polyfill and check for support of `Element.closest` which was introduced in the container fix in v. 1.8.0. ### v 1.8.0 (2016/10/16) ### * Bugfix: Non-visible images being loaded inside container [#23](https://github.com/dinbror/blazy/issues/23) and [#96](https://github.com/dinbror/blazy/issues/96). ### v 1.7.1 (2016/10/14) ### * Bugfix: In safari the picture element always loaded the default/fallback image [#92](https://github.com/dinbror/blazy/issues/92). ### v 1.7.0 (2016/10/10) ### * Bugfix: When lazyloading picture elements it also loaded the fallback/regular image [#92](https://github.com/dinbror/blazy/issues/92) and [108](https://github.com/dinbror/blazy/pull/108). Thanks [@idoshamun](https://github.com/idoshamun) * Refactored loadElement function to avoid redundancy. ### v 1.6.4 (2016/10/08) ### * Bugfix: When lazyloading srcset images it also loaded the fallback/regular image [#99](https://github.com/dinbror/blazy/pull/99). Thanks [@m0uH](https://github.com/m0uH) ### v 1.6.3 (2016/09/30) ### * Changed event listener to passive listener [#106](https://github.com/dinbror/blazy/pull/106). Thanks [@idoshamun](https://github.com/idoshamun) * Added support for web components (shadow dom) [#107](https://github.com/dinbror/blazy/pull/107). Thanks again [@idoshamun](https://github.com/idoshamun) ### v 1.6.2 (2016/05/09) ### * Fixed bug introduced in v.1.6.0, not using retina/breakpoint src [#90](https://github.com/dinbror/blazy/issues/90). ### v 1.6.1 (2016/05/02) ### * Implemented a workaround for onload/onerror bug introduced in chrome v50, [LINK](https://productforums.google.com/forum/#!topic/chrome/p51Lk7vnP2o). Fixed [#85](https://github.com/dinbror/blazy/issues/85). ### v 1.6.0 (2016/04/30) ### * Added support for srcset and the picture element. Fixed [#69](https://github.com/dinbror/blazy/issues/69), [#75](https://github.com/dinbror/blazy/issues/75), [#77](https://github.com/dinbror/blazy/issues/77) and [#82](https://github.com/dinbror/blazy/issues/82). * Added support for lazy load of videos with sources. Fixed [#81](https://github.com/dinbror/blazy/issues/81). * Bugfix. Ensuring that error and success classes won't be added multiple times. Fixed [#84](https://github.com/dinbror/blazy/issues/84). * Marked `breakpoints` as obsolete. Will be removed in upcoming version. Use srcset and/or the picture element instead. ### v 1.5.4 (2016/03/06) ### * Fixed two Safari bugs: [#66](https://github.com/dinbror/blazy/issues/66) and [#78](https://github.com/dinbror/blazy/issues/78). Ensuring "DOM ready". ### v 1.5.3 (2016/03/01) ### * Implemented [#30](https://github.com/dinbror/blazy/pull/30). Keeping data source until success. * Fixed [#47](https://github.com/dinbror/blazy/pull/47). After implementing #30 you can now get the image src and more information in the error/success callbacks. * Added example page to repo `/example/index.html`. ### v 1.5.2 (2015/12/01) ### * Fixed minor bug where the error class was added when calling `revalidate()`. * Minor refactoring ### v 1.5.1 (2015/11/14) ### * Fixed toArray function so it now works in IE7 + 8 again. Bug introduced in 1.4.0. Thanks for reporting [@imcotton](https://github.com/imcotton). * Fixed [#41](https://github.com/dinbror/blazy/pull/41). Added options for validate and saveViewportOffset delay. ### v 1.5.0 (2015/10/30) ### * Added new feature. Now you can lazy load everything with a src attribute like iframes, unity games etc. * Fixed [#45](https://github.com/dinbror/blazy/issues/45). Now you can pass an option if you always want to load invisible images/elements. * Fixed [#49](https://github.com/dinbror/blazy/issues/49). Expanded the `load` function so it's now possible to pass a list of elements instead of only one element. Tested with getElementById, getElementsByClassName, querySelectorAll, querySelector and jQuery selector. * Fixed [#63](https://github.com/dinbror/blazy/issues/63). ### v 1.4.1 (2015/10/12) ### * Fixed [#60](https://github.com/dinbror/blazy/issues/60). An "Uncaught TypeError" when options is null introduced in the refactoring in version 1.4.0. ### v 1.4.0 (2015/09/28) ### * Fixed [#56](https://github.com/dinbror/blazy/issues/56). Now it's possible to create multiple versions of blazy without overriding options. ### v 1.3.1 (2015/02/01) ### * Added support for CommonJS-like environments that support module.exports like [node](http://nodejs.org/). ### v 1.3.0 (2015/01/23) ### * Fixed [#34](https://github.com/dinbror/blazy/issues/34). Expanded public `load` function with force attribute, so you can force hidden images to be loaded. * Fixed [#24](https://github.com/dinbror/blazy/issues/24), [#32](https://github.com/dinbror/blazy/issues/32) and [#35](https://github.com/dinbror/blazy/issues/35). Updated "elementInView" function with intersection check. Thanks @teohhanhui. ### v 1.2.2 (2014/05/04) ### * Fixed [#15](https://github.com/dinbror/blazy/issues/15), when you resize the browser window in another tab bLazy didn't trigger new images in view. Thanks joshribakoff. ### v 1.2.1 (2014/03/23) ### * When lazy loading background images it now only updates the background-image css attribute. Thanks Saku. ### v 1.2.0 (2014/02/15) ### * Important note: renamed option multi to `breakpoints` because it's much more descriptive. * Added [AMD](https://github.com/amdjs/amdjs-api/wiki/AMD) support. * Minor refactoring. ### v 1.1.3 (2014/01/21) ### * Fixed hardcoded retina check (isRetina = true). * Fixed "Uncaught TypeError" when data-src is null. Instead it'll trigger the `error` callback. ### v 1.1.2 (2014/01/03) ### * New feature: After many requests I added the possibility to handle retina images (if you’re not doing retina-first). * New feature: Now you can also lazy load background images. * Added new option, `separator`. Used if you want to pass retina images, default separator is ‘|’. (data-src=“image.jpg|image@2x.jpg”). ### v 1.1.1 (2013/12/27) ### * Fixed #1, resize/scroll events may be detached when adding elements by ajax. * Added new option, `errorClass`. Classname an image will get if something goes wrong, default is ‘b-error’. * Renamed option loadedClass to `successClass` so naming is aligned. Default is still ‘b-loaded’. ### v 1.1.0 (2013/11/22) ### * Renamed success callback from onLoaded to `success`. * Added onerror callback; `error`. * Added the possibility to pass multiple containers instead of one. ### v 1.0.5 (2013/10/7) ### * Fixed "Uncaught TypeError" when container isn't default (window). ### v 1.0.4 (2013/8/29) ### * Added null check so we won't try to load an image if it's missing a data source. ### v 1.0.3 (2013/8/27) ### * Added new option, `loadedClass`. Classname an image will get when loaded. * Added support for horizontal lazy loading. * Reduced throttle time for validate. ### v 1.0.2 (2013/8/7) ### * Fixed typo in unbindEvent function. * Added support for IE7 as promised (fallback for querySelectorAll). ### v 1.0.1 (2013/8/6) ### * Performance improvements. * Added throttle function to ensure that we don't call resize/scroll functions too often. * Cleaning image markup when image has loaded. ##LICENSE: Copyright (c) 2013-16 Bjørn Klinggaard. Licensed under the [The MIT License (MIT)](http://opensource.org/licenses/MIT). libjs-blazy-1.8.2+dfsg/blazy.js000066400000000000000000000340771377272351000163640ustar00rootroot00000000000000/*! hey, [be]Lazy.js - v1.8.2 - 2016.10.25 A fast, small and dependency free lazy load script (https://github.com/dinbror/blazy) (c) Bjoern Klinggaard - @bklinggaard - http://dinbror.dk/blazy */ ; (function(root, blazy) { if (typeof define === 'function' && define.amd) { // AMD. Register bLazy as an anonymous module define(blazy); } else if (typeof exports === 'object') { // Node. Does not work with strict CommonJS, but // only CommonJS-like environments that support module.exports, // like Node. module.exports = blazy(); } else { // Browser globals. Register bLazy on window root.Blazy = blazy(); } })(this, function() { 'use strict'; //private vars var _source, _viewport, _isRetina, _supportClosest, _attrSrc = 'src', _attrSrcset = 'srcset'; // constructor return function Blazy(options) { //IE7- fallback for missing querySelectorAll support if (!document.querySelectorAll) { var s = document.createStyleSheet(); document.querySelectorAll = function(r, c, i, j, a) { a = document.all, c = [], r = r.replace(/\[for\b/gi, '[htmlFor').split(','); for (i = r.length; i--;) { s.addRule(r[i], 'k:v'); for (j = a.length; j--;) a[j].currentStyle.k && c.push(a[j]); s.removeRule(0); } return c; }; } //options and helper vars var scope = this; var util = scope._util = {}; util.elements = []; util.destroyed = true; scope.options = options || {}; scope.options.error = scope.options.error || false; scope.options.offset = scope.options.offset || 100; scope.options.root = scope.options.root || document; scope.options.success = scope.options.success || false; scope.options.selector = scope.options.selector || '.b-lazy'; scope.options.separator = scope.options.separator || '|'; scope.options.containerClass = scope.options.container; scope.options.container = scope.options.containerClass ? document.querySelectorAll(scope.options.containerClass) : false; scope.options.errorClass = scope.options.errorClass || 'b-error'; scope.options.breakpoints = scope.options.breakpoints || false; scope.options.loadInvisible = scope.options.loadInvisible || false; scope.options.successClass = scope.options.successClass || 'b-loaded'; scope.options.validateDelay = scope.options.validateDelay || 25; scope.options.saveViewportOffsetDelay = scope.options.saveViewportOffsetDelay || 50; scope.options.srcset = scope.options.srcset || 'data-srcset'; scope.options.src = _source = scope.options.src || 'data-src'; _supportClosest = Element.prototype.closest; _isRetina = window.devicePixelRatio > 1; _viewport = {}; _viewport.top = 0 - scope.options.offset; _viewport.left = 0 - scope.options.offset; /* public functions ************************************/ scope.revalidate = function() { initialize(scope); }; scope.load = function(elements, force) { var opt = this.options; if (elements && elements.length === undefined) { loadElement(elements, force, opt); } else { each(elements, function(element) { loadElement(element, force, opt); }); } }; scope.destroy = function() { var util = scope._util; if (scope.options.container) { each(scope.options.container, function(object) { unbindEvent(object, 'scroll', util.validateT); }); } unbindEvent(window, 'scroll', util.validateT); unbindEvent(window, 'resize', util.validateT); unbindEvent(window, 'resize', util.saveViewportOffsetT); util.count = 0; util.elements.length = 0; util.destroyed = true; }; //throttle, ensures that we don't call the functions too often util.validateT = throttle(function() { validate(scope); }, scope.options.validateDelay, scope); util.saveViewportOffsetT = throttle(function() { saveViewportOffset(scope.options.offset); }, scope.options.saveViewportOffsetDelay, scope); saveViewportOffset(scope.options.offset); //handle multi-served image src (obsolete) each(scope.options.breakpoints, function(object) { if (object.width >= window.screen.width) { _source = object.src; return false; } }); // start lazy load setTimeout(function() { initialize(scope); }); // "dom ready" fix }; /* Private helper functions ************************************/ function initialize(self) { var util = self._util; // First we create an array of elements to lazy load util.elements = toArray(self.options); util.count = util.elements.length; // Then we bind resize and scroll events if not already binded if (util.destroyed) { util.destroyed = false; if (self.options.container) { each(self.options.container, function(object) { bindEvent(object, 'scroll', util.validateT); }); } bindEvent(window, 'resize', util.saveViewportOffsetT); bindEvent(window, 'resize', util.validateT); bindEvent(window, 'scroll', util.validateT); } // And finally, we start to lazy load. validate(self); } function validate(self) { var util = self._util; for (var i = 0; i < util.count; i++) { var element = util.elements[i]; if (elementInView(element, self.options) || hasClass(element, self.options.successClass)) { self.load(element); util.elements.splice(i, 1); util.count--; i--; } } if (util.count === 0) { self.destroy(); } } function elementInView(ele, options) { var rect = ele.getBoundingClientRect(); if(options.container && _supportClosest){ // Is element inside a container? var elementContainer = ele.closest(options.containerClass); if(elementContainer){ var containerRect = elementContainer.getBoundingClientRect(); // Is container in view? if(inView(containerRect, _viewport)){ var top = containerRect.top - options.offset; var right = containerRect.right + options.offset; var bottom = containerRect.bottom + options.offset; var left = containerRect.left - options.offset; var containerRectWithOffset = { top: top > _viewport.top ? top : _viewport.top, right: right < _viewport.right ? right : _viewport.right, bottom: bottom < _viewport.bottom ? bottom : _viewport.bottom, left: left > _viewport.left ? left : _viewport.left }; // Is element in view of container? return inView(rect, containerRectWithOffset); } else { return false; } } } return inView(rect, _viewport); } function inView(rect, viewport){ // Intersection return rect.right >= viewport.left && rect.bottom >= viewport.top && rect.left <= viewport.right && rect.top <= viewport.bottom; } function loadElement(ele, force, options) { // if element is visible, not loaded or forced if (!hasClass(ele, options.successClass) && (force || options.loadInvisible || (ele.offsetWidth > 0 && ele.offsetHeight > 0))) { var dataSrc = getAttr(ele, _source) || getAttr(ele, options.src); // fallback to default 'data-src' if (dataSrc) { var dataSrcSplitted = dataSrc.split(options.separator); var src = dataSrcSplitted[_isRetina && dataSrcSplitted.length > 1 ? 1 : 0]; var srcset = getAttr(ele, options.srcset); var isImage = equal(ele, 'img'); var parent = ele.parentNode; var isPicture = parent && equal(parent, 'picture'); // Image or background image if (isImage || ele.src === undefined) { var img = new Image(); // using EventListener instead of onerror and onload // due to bug introduced in chrome v50 // (https://productforums.google.com/forum/#!topic/chrome/p51Lk7vnP2o) var onErrorHandler = function() { if (options.error) options.error(ele, "invalid"); addClass(ele, options.errorClass); unbindEvent(img, 'error', onErrorHandler); unbindEvent(img, 'load', onLoadHandler); }; var onLoadHandler = function() { // Is element an image if (isImage) { if(!isPicture) { handleSources(ele, src, srcset); } // or background-image } else { ele.style.backgroundImage = 'url("' + src + '")'; } itemLoaded(ele, options); unbindEvent(img, 'load', onLoadHandler); unbindEvent(img, 'error', onErrorHandler); }; // Picture element if (isPicture) { img = ele; // Image tag inside picture element wont get preloaded each(parent.getElementsByTagName('source'), function(source) { handleSource(source, _attrSrcset, options.srcset); }); } bindEvent(img, 'error', onErrorHandler); bindEvent(img, 'load', onLoadHandler); handleSources(img, src, srcset); // Preload } else { // An item with src like iframe, unity games, simpel video etc ele.src = src; itemLoaded(ele, options); } } else { // video with child source if (equal(ele, 'video')) { each(ele.getElementsByTagName('source'), function(source) { handleSource(source, _attrSrc, options.src); }); ele.load(); itemLoaded(ele, options); } else { if (options.error) options.error(ele, "missing"); addClass(ele, options.errorClass); } } } } function itemLoaded(ele, options) { addClass(ele, options.successClass); if (options.success) options.success(ele); // cleanup markup, remove data source attributes removeAttr(ele, options.src); removeAttr(ele, options.srcset); each(options.breakpoints, function(object) { removeAttr(ele, object.src); }); } function handleSource(ele, attr, dataAttr) { var dataSrc = getAttr(ele, dataAttr); if (dataSrc) { setAttr(ele, attr, dataSrc); removeAttr(ele, dataAttr); } } function handleSources(ele, src, srcset){ if(srcset) { setAttr(ele, _attrSrcset, srcset); //srcset } ele.src = src; //src } function setAttr(ele, attr, value){ ele.setAttribute(attr, value); } function getAttr(ele, attr) { return ele.getAttribute(attr); } function removeAttr(ele, attr){ ele.removeAttribute(attr); } function equal(ele, str) { return ele.nodeName.toLowerCase() === str; } function hasClass(ele, className) { return (' ' + ele.className + ' ').indexOf(' ' + className + ' ') !== -1; } function addClass(ele, className) { if (!hasClass(ele, className)) { ele.className += ' ' + className; } } function toArray(options) { var array = []; var nodelist = (options.root).querySelectorAll(options.selector); for (var i = nodelist.length; i--; array.unshift(nodelist[i])) {} return array; } function saveViewportOffset(offset) { _viewport.bottom = (window.innerHeight || document.documentElement.clientHeight) + offset; _viewport.right = (window.innerWidth || document.documentElement.clientWidth) + offset; } function bindEvent(ele, type, fn) { if (ele.attachEvent) { ele.attachEvent && ele.attachEvent('on' + type, fn); } else { ele.addEventListener(type, fn, { capture: false, passive: true }); } } function unbindEvent(ele, type, fn) { if (ele.detachEvent) { ele.detachEvent && ele.detachEvent('on' + type, fn); } else { ele.removeEventListener(type, fn, { capture: false, passive: true }); } } function each(object, fn) { if (object && fn) { var l = object.length; for (var i = 0; i < l && fn(object[i], i) !== false; i++) {} } } function throttle(fn, minDelay, scope) { var lastCall = 0; return function() { var now = +new Date(); if (now - lastCall < minDelay) { return; } lastCall = now; fn.apply(scope, arguments); }; } }); libjs-blazy-1.8.2+dfsg/bower.json000066400000000000000000000011571377272351000167070ustar00rootroot00000000000000{ "name": "bLazy", "main": "blazy.js", "version": "1.8.2", "description": "A fast lightweight pure JavaScript script for lazy loading and multi-serving images, iframes, videos and more.", "homepage": "https://github.com/dinbror/blazy", "keywords": [ "blazy", "lazy", "lazyload", "lazyloading", "retina", "responsive", "image", "images", "picture", "srcset", "javascript", "performance" ], "authors": [ { "name": "Bjørn Klinggaard", "url": "http://dinbror.dk", "email": "hello@dinbror.dk" } ], "license": "MIT", "moduleType": [ "amd", "CommonJS" ], "ignore": [] } libjs-blazy-1.8.2+dfsg/example/000077500000000000000000000000001377272351000163255ustar00rootroot00000000000000libjs-blazy-1.8.2+dfsg/example/index.html000066400000000000000000000313771377272351000203350ustar00rootroot00000000000000 blazy.js - lazyload examples

blazy.js

Blazy is a fast, SEO friendly and small but still feature-rich lazy load script. It was originally build for lazy loading images but it can also lazy load any element with a source attribute like iframes, unity games, html5 videos, scripts etc.

Blazy comes with a bunch of features like serving retina images for retina screens, multi-serve images depending on screensize and error handling. For a list of all features and more details you can visit the blog post. Blazy works in all modern browsers including IE7+.

How to lazyload

  1. Add blazy.js to your website
  2. Add the 'b-lazy' class to the elements that should be lazy loaded
  3. Initialize blazy whenever you're ready

        var bLazy = new Blazy({
            // Options
        });
    				

Examples

  1. Lazy load images, regular, retina, srcset and picture element
  2. Lazy load background image
  3. Lazy load inside container (vertical & horizotal)
  4. Lazy load iframe
  5. Lazy load HTML5 video
  6. Lazy load script file

1.1: Default lazyload image example

Lazy load images example 1a
    <img class="b-lazy" data-src="image.jpg" />
			

1.2: Lazy load image example with css effect

Lazy load images example 1b
  CSS:
  
    .b-lazy {
       opacity:0;
       transform: scale(3);
       transition: all 500ms;
    }
    .b-loaded {
       opacity:1;
       transform: scale(1);
    }
			

1.3: Lazy load image example with low res image placeholder

Lazy load images example 1c
    <img class="b-lazy" src="low-res-image.jpg" data-src="image.jpg" />
			

1.4: Lazy load image example with srcset

Lazy load image example with srcset
   <img class="b-lazy" 
        sizes="100vw"
        data-srcset="large.jpg 1024w, medium.jpg 640w, small.jpg 320w"
        data-src="medium.jpg" />
			

1.5: Lazy load image example with picture element

Lazy load image example with picture element
    <picture> 
        <source 
             media="(min-width: 650px)"
             data-srcset="image-650.jpg" /> 
        <source 
             media="(min-width: 465px)" 
             data-srcset="image-465.jpg" />
        <img class="b-lazy"
             data-src="default.jpg" />
    </picture>
			

1.6: Lazyload image with retina support example

Lazy load images example 1a
    <img class="b-lazy" data-src="image.jpg|retina-image.jpg" />
			

2: Lazy load background image example

    <div class="b-lazy" data-src="image.jpg"></div>
			

3.1: Horizontal lazyload inside container example

  • Lazy load images example 3 image 1
  • Lazy load images example 3 image 2
  • Lazy load images example 3 image 3
    var blazy = new Blazy({
	container: '.container'
    });
			

3.2: Vertical lazyload inside container example

  • Lazy load images example 3 image 1
  • Lazy load images example 3 image 2
  • Lazy load images example 3 image 3
    var blazy = new Blazy({
	container: '.container'
    });
			

4: Lazy load iframe example

    <iframe class="b-lazy" 
	    data-src="https://www.youtube.com/embed/uKtjVQ5IJOQ" 
	    frameborder="0" 
	    allowfullscreen>
    </iframe>
			

5.1: Lazy load HTML5 video example

    <video class="b-lazy" data-src="video.mp4" controls></video>
			

5.2: Lazy load HTML5 video advanced example

    <video class="b-lazy" controls>
        <source data-src="video.mp4" type="video/mp4">
        <source data-src="video.webm" type="video/webm">
        Your browser doesn't support HTML5 video tag.
    </video>
			

6: Lazy load script example

Check the console log

    <script class="b-lazy" data-src="script.js" async></script>
			
libjs-blazy-1.8.2+dfsg/package.json000066400000000000000000000015471377272351000171670ustar00rootroot00000000000000{ "name": "blazy", "version": "1.8.2", "description": "A fast lightweight pure JavaScript script for lazy loading and multi-serving images, iframes, videos and more.", "main": "blazy.js", "keywords": [ "blazy", "blazyjs", "blazy.js", "lazy", "lazyload", "lazyloading", "image", "images", "picture", "srcset", "iframe", "video", "unity", "retina", "responsive", "performance" ], "author": "Bjørn Klinggaard (http://dinbror.dk/blazy)", "repository": { "type": "git", "url": "git://github.com/dinbror/blazy.git" }, "bugs": { "url": "https://github.com/dinbror/blazy/issues" }, "license": "MIT", "homepage": "https://github.com/dinbror/blazy", "scripts": { "test": "echo \"Error: no test specified\" && exit 1" }, "directories": { "example": "example" } } libjs-blazy-1.8.2+dfsg/polyfills/000077500000000000000000000000001377272351000167075ustar00rootroot00000000000000libjs-blazy-1.8.2+dfsg/polyfills/closest.js000066400000000000000000000020601377272351000207170ustar00rootroot00000000000000// Polyfill for Element.closest that falls back to Element.matches that falls back to querySelectorAll // Created for blazy.js 1.8.1 - https://github.com/dinbror/blazy to ensure IE7+ support (function () { if (!Element.prototype.matches) { Element.prototype.matches = Element.prototype.matchesSelector || Element.prototype.mozMatchesSelector || Element.prototype.msMatchesSelector || Element.prototype.oMatchesSelector || Element.prototype.webkitMatchesSelector || function(s) { var matches = (this.document || this.ownerDocument).querySelectorAll(s), i = matches.length; while (--i >= 0 && matches.item(i) !== this) {} return i > -1; }; } if (!Element.prototype.closest) { Element.prototype.closest = Element.prototype.closest || function(selector) { var element = this; while (element.matches && !element.matches(selector)) element = element.parentNode; return element.matches ? element : null; }; } })();