loading-attribute-polyfill
Advanced tools
Comparing version 0.1.2 to 0.2.0
{ | ||
"name": "loading-attribute-polyfill", | ||
"description": "A minimal and dependency-free vanilla JavaScript polyfill for the awesome loading='lazy'-attribute.", | ||
"version": "0.1.1", | ||
"version": "0.2.0", | ||
"homepage": "https://github.com/mfranzke/loading-attribute-polyfill", | ||
@@ -6,0 +6,0 @@ "authors": [ |
@@ -7,2 +7,3 @@ # Changelog | ||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). | ||
And the commit messages from [Conventional Commits](https://conventionalcommits.org) are being used. | ||
@@ -15,2 +16,25 @@ ## [Unreleased] | ||
## [0.2.0] - 2019-05-22 | ||
### Added | ||
- Changelog | ||
- Codacy integration and badge | ||
- Code examples | ||
- Optional additional dependencies section within the README | ||
- Optional polyfill for the demo page | ||
- "Conventional Commits" support as well as their badge - yeah ! | ||
### Changed | ||
- Docs formatting | ||
- Some docs content enhancements | ||
- Internal namings within the JS file | ||
## [0.1.2] - 2019-05-04 | ||
### Added | ||
- Documentation | ||
## [0.1.1] - 2019-05-01 | ||
@@ -17,0 +41,0 @@ |
@@ -31,8 +31,8 @@ /* | ||
// On using a browser w/o requestAnimationFrame support (IE9, Opera Mini), just run the passed function | ||
var requestanimationframe; | ||
var rAFWrapper; | ||
if ('requestAnimationFrame' in window) { | ||
requestanimationframe = window.requestAnimationFrame; | ||
rAFWrapper = window.requestAnimationFrame; | ||
} else { | ||
requestanimationframe = function(func) { | ||
rAFWrapper = function(func) { | ||
func(); | ||
@@ -152,2 +152,3 @@ }; | ||
entries.forEach(function(entry) { | ||
// Mitigation for EDGE lacking support of .isIntersecting until v15, compare to e.g. https://github.com/w3c/IntersectionObserver/issues/211#issuecomment-309144669 | ||
if (entry.intersectionRatio === 0) { | ||
@@ -229,6 +230,6 @@ return; | ||
if (/comp|inter/.test(document.readyState)) { | ||
requestanimationframe(prepareElements); | ||
rAFWrapper(prepareElements); | ||
} else if ('addEventListener' in document) { | ||
document.addEventListener('DOMContentLoaded', function() { | ||
requestanimationframe(prepareElements); | ||
rAFWrapper(prepareElements); | ||
}); | ||
@@ -235,0 +236,0 @@ } else { |
{ | ||
"name": "loading-attribute-polyfill", | ||
"version": "0.1.2", | ||
"version": "0.2.0", | ||
"description": "A minimal and dependency-free vanilla JavaScript polyfill for the awesome loading='lazy'-attribute.", | ||
@@ -5,0 +5,0 @@ "main": "loading-attribute-polyfill.min.js", |
# loading="lazy" attribute polyfill | ||
*Work in progress* | ||
[![MIT license](https://img.shields.io/npm/l/loading-attribute-polyfill.svg 'license badge')](https://opensource.org/licenses/mit-license.php) | ||
[![loading-attribute-polyfill on Npmjs](https://img.shields.io/npm/v/loading-attribute-polyfill.svg 'npm version')][npm] | ||
[![Total downloads ~ Npmjs](https://img.shields.io/npm/dt/loading-attribute-polyfill.svg 'Count of total downloads – NPM')][npm] | ||
[![jsDelivr CDN downloads](https://data.jsdelivr.com/v1/package/npm/loading-attribute-polyfill/badge 'Count of total downloads – jsDelivr')](https://www.jsdelivr.com/package/npm/loading-attribute-polyfill 'loading-attribute polyfill – on jsDelivr') | ||
_Work in progress_ | ||
[![MIT license](https://img.shields.io/npm/l/loading-attribute-polyfill.svg "license badge")](https://opensource.org/licenses/mit-license.php) | ||
[![loading-attribute-polyfill on Npmjs](https://img.shields.io/npm/v/loading-attribute-polyfill.svg "npm version")][npm] | ||
[![Total downloads ~ Npmjs](https://img.shields.io/npm/dt/loading-attribute-polyfill.svg "Count of total downloads – NPM")][npm] | ||
[![jsDelivr CDN downloads](https://data.jsdelivr.com/v1/package/npm/loading-attribute-polyfill/badge "Count of total downloads – jsDelivr")](https://www.jsdelivr.com/package/npm/loading-attribute-polyfill "loading-attribute polyfill – on jsDelivr") | ||
[![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettier) | ||
[![XO code style](https://img.shields.io/badge/code_style-XO-5ed9c7.svg)](https://github.com/xojs/xo) | ||
[![Conventional Commits](https://img.shields.io/badge/Conventional%20Commits-1.0.0-yellow.svg)](https://conventionalcommits.org) | ||
Fast and lightweight vanilla JavaScript polyfill for the native behaviour to load elements right before they enter the viewport. Provides graceful degradation, and is - not just thatfor - SEO friendly. Handles images with srcset and within picture, as well as iframes. loading="lazy" will be a huge improve for todays web performance challenges, so use and polyfill it today! | ||
- Supports the standard loading="lazy" attribute | ||
- Supports the standard loading="lazy" attribute on `image` and `iframe` elements | ||
- Released under the MIT license | ||
@@ -19,3 +21,3 @@ - Made in Germany | ||
*TBD* | ||
_TBD_ | ||
@@ -45,3 +47,3 @@ ## Core concepts | ||
<img | ||
src="https://imgplaceholder.com/250x150/fbfbfb/0f0f0f?font-family=OpenSans_Bold&text=img_br_src_br_loading%3D%22lazy%22" | ||
src="simpleimage.jpg" | ||
loading="lazy" | ||
@@ -62,4 +64,4 @@ alt=".." | ||
srcset=" | ||
https://imgplaceholder.com/250x150/fbfbfb/0f0f0f?font-family=OpenSans_Bold&text=picture_br_media+1x_br_loading%3D%22lazy%22 1x, | ||
https://imgplaceholder.com/500x500/fbfbfb/0f0f0f?font-family=OpenSans_Bold&text=picture_br_media+2x_br_loading%3D%22lazy%22 2x | ||
simpleimage.huge.jpg 1x, | ||
simpleimage.huge.2x.jpg 2x | ||
" | ||
@@ -69,4 +71,4 @@ /> | ||
srcset=" | ||
https://imgplaceholder.com/250x150/fbfbfb/0f0f0f?font-family=OpenSans_Bold&text=picture_br_1x_br_loading%3D%22lazy%22 1x, | ||
https://imgplaceholder.com/500x500/fbfbfb/0f0f0f?font-family=OpenSans_Bold&text=picture_br_2x_br_loading%3D%22lazy%22 2x | ||
simpleimage.jpg 1x, | ||
simpleimage.2x.jpg 2x | ||
" | ||
@@ -76,3 +78,3 @@ /> | ||
<img | ||
src="https://imgplaceholder.com/250x150/fbfbfb/0f0f0f?font-family=OpenSans_Bold&text=picture_br_img+src_br_loading%3D%22lazy%22" | ||
src="simpleimage.jpg" | ||
loading="lazy" | ||
@@ -92,7 +94,7 @@ alt=".." | ||
<img | ||
src="https://imgplaceholder.com/250x150/fbfbfb/0f0f0f?font-family=OpenSans_Bold&text=img_br_src_br_loading%3D%22lazy%22" | ||
src="simpleimage.jpg" | ||
srcset=" | ||
https://imgplaceholder.com/1024x400/fbfbfb/0f0f0f?font-family=OpenSans_Bold&text=img_br_srcset+1024w_br_loading%3D%22lazy%22 1024w, | ||
https://imgplaceholder.com/640x400/fbfbfb/0f0f0f?font-family=OpenSans_Bold&text=img_br_srcset+640w_br_loading%3D%22lazy%22 640w, | ||
https://imgplaceholder.com/320x320/fbfbfb/0f0f0f?font-family=OpenSans_Bold&text=img_br_srcset+320w_br_loading%3D%22lazy%22 320w | ||
simpleimage.1024.jpg 1024w, | ||
simpleimage.640.jpg 640w, | ||
simpleimage.320.jpg 320w | ||
" | ||
@@ -125,3 +127,3 @@ sizes="(min-width: 36em) 33.3vw, 100vw" | ||
Nevertheless this polyfill would still work in those browsers without that other polyfill included, but [this small amount of users]((https://caniuse.com/#feat=intersectionobserver)) wouldn't totally benefit from the lazy loading functionality - we've at least got you partly covered by using the [Microsoft proprietary lazyloading resource hints](https://caniuse.com/#feat=lazyload). | ||
Nevertheless this polyfill would still work in those browsers without that other polyfill included, but [this small amount of users](<(https://caniuse.com/#feat=intersectionobserver)>) wouldn't totally benefit from the lazy loading functionality - we've at least got you partly covered by using the [Microsoft proprietary lazyloading resource hints](https://caniuse.com/#feat=lazyload). | ||
@@ -128,0 +130,0 @@ ## API |
Sorry, the diff of this file is not supported yet
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
25620
236
136