forked from dinbror/blazy to be used as drupal-library
Table of Contents
More examples: http://dinbror.dk/blazy/examples/
Codepen playground: http://codepen.io/dinbror/pen/HzCAJ
You can install blazy.js with npm:
npm install blazy --save
bower install blazy --save
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.
latest with the specific version number if you want to lock it in.
- bLazy is used on big sites with millions of monthly visitors so it has been tested out in the real world.
- 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.
- Only preload "first frame" of progressive jpegs.
- Add support for CSS background property; image-set (caniuse).
- 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.
- Added null check in public
- Bugfix: Fixed
thisissue defaulting to window when passing
destroyin setTimeout as reference #73 and #112. Thanks PeteDuncanson.
- Bugfix: If parts of container is outside window use the viewport boundaries #113 and #114. Thanks dbirkbeck.
- Bugfix: Created polyfill and check for support of
Element.closestwhich was introduced in the container fix in v. 1.8.0.
- Bugfix: In safari the picture element always loaded the default/fallback image #92.
- Bugfix: When lazyloading picture elements it also loaded the fallback/regular image #92 and 108. Thanks @idoshamun
- Refactored loadElement function to avoid redundancy.
- Changed event listener to passive listener #106. Thanks @idoshamun
- Added support for web components (shadow dom) #107. Thanks again @idoshamun
- Fixed bug introduced in v.1.6.0, not using retina/breakpoint src #90.
- Added support for srcset and the picture element. Fixed #69, #75, #77 and #82.
- Added support for lazy load of videos with sources. Fixed #81.
- Bugfix. Ensuring that error and success classes won't be added multiple times. Fixed #84.
breakpointsas obsolete. Will be removed in upcoming version. Use srcset and/or the picture element instead.
- Implemented #30. Keeping data source until success.
- Fixed #47. After implementing #30 you can now get the image src and more information in the error/success callbacks.
- Added example page to repo
- Fixed minor bug where the error class was added when calling
- Minor refactoring
- Fixed toArray function so it now works in IE7 + 8 again. Bug introduced in 1.4.0. Thanks for reporting @imcotton.
- Fixed #41. Added options for validate and saveViewportOffset delay.
- Added new feature. Now you can lazy load everything with a src attribute like iframes, unity games etc.
- Fixed #45. Now you can pass an option if you always want to load invisible images/elements.
- Fixed #49. Expanded the
loadfunction 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.
- Fixed #60. An "Uncaught TypeError" when options is null introduced in the refactoring in version 1.4.0.
- Fixed #56. Now it's possible to create multiple versions of blazy without overriding options.
- Added support for CommonJS-like environments that support module.exports like node.
- Fixed #34. Expanded public
loadfunction with force attribute, so you can force hidden images to be loaded.
- Fixed #24, #32 and #35. Updated "elementInView" function with intersection check. Thanks @teohhanhui.
- Fixed #15, when you resize the browser window in another tab bLazy didn't trigger new images in view. Thanks joshribakoff.
- When lazy loading background images it now only updates the background-image css attribute. Thanks Saku.
- Important note: renamed option multi to
breakpointsbecause it's much more descriptive.
- Added AMD support.
- Minor refactoring.
- Fixed hardcoded retina check (isRetina = true).
- Fixed "Uncaught TypeError" when data-src is null. Instead it'll trigger the
- 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=“email@example.com”).
- 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
successClassso naming is aligned. Default is still ‘b-loaded’.
- Renamed success callback from onLoaded to
- Added onerror callback;
- Added the possibility to pass multiple containers instead of one.
- Fixed "Uncaught TypeError" when container isn't default (window).
- Added null check so we won't try to load an image if it's missing a data source.
- Added new option,
loadedClass. Classname an image will get when loaded.
- Added support for horizontal lazy loading.
- Reduced throttle time for validate.
- Fixed typo in unbindEvent function.
- Added support for IE7 as promised (fallback for querySelectorAll).
- 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).