Skip to content

Commit 7e8dde4

Browse files
author
aFarkas
committed
0.5.1
1 parent 990e04f commit 7e8dde4

File tree

6 files changed

+21
-11
lines changed

6 files changed

+21
-11
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ The LQIP pattern (low quality image placeholder): Simply add a low quality image
9292
<img src="lqip-src.jpg" data-src="image.jpg" class="lazyload" />
9393
```
9494

95-
The LQIP pattern has the following advantages: The lqip-src is not hidden from the preload parser and loads very fast, which leads to an extreme fast first impression and in case of legacy browsers/devices or searchengines (bots) as a good enough fallback (IE8 and Android 2 devices as also JS disabled). In case your lqip source is extreme fuzzy, you should consider serving either a higher quality, setting ``preloadAfterLoad`` to ``true`` or use the "noscript" pattern. The human eye/brain dislikes too heavy image quality jumps...
95+
The LQIP pattern has the following advantages: The lqip-src is not hidden from the preload parser and loads very fast, which leads to an extreme fast first impression and in case of legacy browsers/devices or searchengines (bots) as a good enough fallback (IE8 and Android 2 devices as also JS disabled). In case your lqip source is extreme fuzzy, you should consider serving either a higher quality, setting ``preloadAfterLoad`` to ``true`` or use the "noscript" or the "SEO" pattern. The human eye/brain dislikes too heavy image quality jumps...
9696

9797
###The noscript pattern
9898
In case you want to save more initial image data the LQIP pattern can't be used (an extreme fuzzy image does neither work as a good enough first impression nor as a fallback) or in case you can't even generate a LQIP src, but the image is important you can use the noscript pattern, which uses a 1x1 pixel grey image combined with a noscript tag:
@@ -129,7 +129,7 @@ In case you don't need to account for JS off or legacy browers, but still for se
129129
<meta itemprop="contentUrl" content="image.jpg" />
130130
<meta itemprop="name" content="my image" />
131131
</span>
132-
<img src="data:image/gif;base64,R0lGODlhAQABAAAAADs="
132+
<img src="data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw=="
133133
class="lazyload"
134134
data-srcset="image.jpg 1x, image2.jpg 2x"
135135
alt="my image" />

bower.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "lazysizes",
33
"repo": "afarkas/lazysizes",
4-
"version": "0.5.0",
4+
"version": "0.5.1",
55
"main": "lazysizes.min.js",
66
"scripts": [
77
"lazysizes.min.js"

component.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "lazysizes",
3-
"version": "0.5.0",
3+
"version": "0.5.1",
44
"repo": "afarkas/lazysizes",
55
"main": "lazysizes.min.js",
66
"scripts": ["lazysizes.min.js"],

lazysizes.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "lazysizes",
3-
"version": "0.5.0",
3+
"version": "0.5.1",
44
"author": "Alexander Farkas <[email protected]>",
55
"repository": {
66
"type": "git",

plugins/optimumx/ls.optimumx.js

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -78,26 +78,36 @@
7878
}
7979

8080
function takeHighRes(beforeCan, curCanWidth, width){
81-
var low, high;
81+
var low, high, curRes;
8282
if(!beforeCan || !beforeCan.w){
8383
return true;
8484
}
85+
curRes = beforeCan.w / width;
8586
low = (1 - (beforeCan.w / width)) * 0.9;
8687
high = (curCanWidth / width) - 1;
88+
89+
high *= Math.pow(curRes, 1.3);
90+
8791
return high - low < 0;
8892
}
8993

9094
function getConstrainedSrcSet(data, width){
91-
var i, can;
95+
var i, can, take;
9296

9397
for(i = data.index + 1; i < data.cands.length; i++){
9498
can = data.cands[i];
95-
if(!can.w || can.w <= width || takeHighRes(data.cands[i - 1], can.w, width)){
96-
data.cSrcset.push(can.url +' '+ can.w + 'w');
97-
data.index = i;
99+
take = false;
100+
if(!can.w && can.x){
101+
take = 'x';
102+
} else if(can.w <= width || takeHighRes(data.cands[i - 1], can.w, width)){
103+
take = 'w';
98104
} else {
99105
break;
100106
}
107+
if(take){
108+
data.cSrcset.push(can.url +' '+ can[take] + take);
109+
data.index = i;
110+
}
101111
}
102112
}
103113

0 commit comments

Comments
 (0)