-
Notifications
You must be signed in to change notification settings - Fork 1.7k
/
index.html
850 lines (776 loc) · 32.2 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>lazysizes - the ultimate lazyloader for responsive images, iframes and widget</title>
<link rel="canonical" href="https://afarkas.github.io/lazysizes/index.html" />
<script>
function loadJS(u){var r=document.getElementsByTagName("script")[ 0 ],s=document.createElement("script");s.src=u;r.parentNode.insertBefore(s,r);}
if(!window.HTMLPictureElement || !('sizes' in document.createElement('img'))){
document.createElement('picture');
loadJS("plugins/respimg/ls.respimg.min.js");
}
</script>
<link href="assets/css/tidy.css" rel="stylesheet" />
<style>
.nav {
margin-bottom: 30px;
}
.intrinsic {
position: relative;
padding-bottom: 75%;
height: 0;
}
.intrinsic-2 {
padding-bottom: 56.25%;
}
.intrinsic-3 {
padding-bottom: 133.333%;
}
.intrinsic img,
.intrinsic iframe,
.intrinsic .lazyload {
position:absolute;
width: 100%;
height: 100%;
left: 0;
top: 0;
border: none;
overflow: hidden;
}
.thumbnail-small {
width: 32%;
display: inline-block;
margin-bottom: 35px;
}
pre {
-moz-tab-size: 2;
tab-size: 2;
}
.scroll-view {
overflow: auto;
overflow-x: auto;
overflow-y: hidden;
-webkit-overflow-scrolling: touch;
position: relative;
width: 100%;
padding: 2px 2px 10px;
}
.scroll-doc {
display: table;
position: relative;
text-align: left;
}
.scroll-item {
display: table-cell;
vertical-align: middle;
}
.scroll-item .thumbnail {
margin: 5px 10px;
width: 230px;
}
.scroll-item .thumbnail img {
width: 100%;
height: auto;
}
.no-src.lazyload,
.no-src.lazyloading {
opacity: 0;
}
.no-src.lazyloaded {
opacity: 1;
transition: opacity 300ms;
}
[data-expand].lazyload {
opacity: 0;
transform: scale(0.8);
}
[data-expand].lazyloaded {
opacity: 1;
transition: all 700ms;
transform: scale(1);
}
.effect-row-middle > [data-expand]:nth-child(2),
.effect-row-reverse > [data-expand]:nth-child(3),
.effect-row > [data-expand]:nth-child(1) {
transition-delay: 100ms;
}
.effect-row-middle > [data-expand]:nth-child(1),
.effect-row-middle > [data-expand]:nth-child(3),
.effect-row-reverse > [data-expand]:nth-child(2),
.effect-row > [data-expand]:nth-child(2) {
transition-delay: 400ms;
}
.effect-row-reverse > [data-expand]:nth-child(1),
.effect-row > [data-expand]:nth-child(3) {
transition-delay: 700ms;
}
/*.blur-up {*/
/*-webkit-filter: blur(4px);*/
/*filter: blur(4px);*/
/*transition: filter 400ms, -webkit-filter 400ms;*/
/*}*/
/*.blur-up.lazyloaded {*/
/*-webkit-filter: blur(0);*/
/*filter: blur(0);*/
/*}*/
</style>
<script>
(function(){
var docElem = document.documentElement;
window.lazySizesConfig = window.lazySizesConfig || {};
window.lazySizesConfig.loadMode = 1;
//set expand to a higher value on larger displays
window.lazySizesConfig.expand = Math.max(Math.min(docElem.clientWidth, docElem.clientHeight, 1222) - 1, 359);
window.lazySizesConfig.expFactor = lazySizesConfig.expand < 380 ? 3 : 2;
})();
</script>
<script src="plugins/unveilhooks/ls.unveilhooks.min.js" async=""></script>
<script src="lazysizes.min.js" async=""></script>
</head>
<body>
<div class="container">
<div class="jumbotron">
<h1>lazySizes</h1>
<p><strong>lazySizes</strong> is the ultimate and lightweight lazyLoader which lazy loads images (including responsive images (picture/srcset)), iframes and scripts. It is written in VanillaJS and with high performance in mind.</p>
<p>Simply add the JS to your website and put the <code>class</code> <code>lazyload</code> to all elements, which should be lazy loaded. For a short <a href="https://github.com/aFarkas/lazysizes/blob/gh-pages/README.md">API description go to the readme.md</a>.</p>
</div>
<div id="examples">
<div class="row">
<div class="col-sm-12">
<div class="thumbnail">
<div class="intrinsic">
<img
alt="bird"
src="https://images.unsplash.com/photo-1470116073782-48ae2ccd8ffd?ixlib=rb-1.2.1&auto=format&fit=crop&w=100"
data-src="https://images.unsplash.com/photo-1470116073782-48ae2ccd8ffd?ixlib=rb-1.2.1&auto=format&fit=crop&w=1600&q=80"
class="lazyload" />
</div>
<div class="caption">
<h3>Image with LQIP technique</h3>
<p>The low quality image placeholder pattern uses a low quality image for the first impression.</p>
<pre><img
alt="bird"
src="low-quality.jpg"
data-src="normal-quality.jpg"
class="lazyload" />
</pre>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-sm-12">
<div class="thumbnail">
<div class="intrinsic">
<img alt="Mountain" data-src="https://images.unsplash.com/photo-1544198365-f5d60b6d8190?ixlib=rb-1.2.1&auto=format&fit=crop&w=1130&q=80" class="lazyload no-src" />
</div>
<div class="caption">
<h3>Normal lazy image</h3>
<p>Of course the low quality image can be simply omitted to save more image data.</p>
<pre><img class="lazyload" data-src="image.jpg" alt="Mountain" />
</pre>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-sm-12">
<div class="thumbnail">
<div class="intrinsic">
<img
alt="Jellyfish"
sizes="(min-width: 1000px) 930px, 90vw"
data-sizes="auto"
data-src="https://images.unsplash.com/photo-1523264629844-40dd6bf17c2b?ixlib=rb-1.2.1&auto=format&fit=crop&w=1024&q=60"
data-srcset="https://images.unsplash.com/photo-1523264629844-40dd6bf17c2b?ixlib=rb-1.2.1&auto=format&fit=crop&w=240&q=60 240w,
https://images.unsplash.com/photo-1523264629844-40dd6bf17c2b?ixlib=rb-1.2.1&auto=format&fit=crop&w=320&q=60 320w,
https://images.unsplash.com/photo-1523264629844-40dd6bf17c2b?ixlib=rb-1.2.1&auto=format&fit=crop&w=500&q=60 500w,
https://images.unsplash.com/photo-1523264629844-40dd6bf17c2b?ixlib=rb-1.2.1&auto=format&fit=crop&w=640&q=60 640w,
https://images.unsplash.com/photo-1523264629844-40dd6bf17c2b?ixlib=rb-1.2.1&auto=format&fit=crop&w=1024&q=60 1024w"
class="lazyload no-src" />
</div>
<div class="caption">
<h3>responsive image with srcset and sizes attribute</h3>
<p>Simply use <code>data-srcset</code> and you can support responsive images.</p>
<pre><img
alt="Jellyfish"
sizes="(min-width: 1000px) 930px, 90vw"
data-srcset="small.jpg 500w,
medium.jpg 640w,
big.jpg 1024w"
data-src="medium.jpg"
class="lazyload" />
</pre>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-sm-12">
<div class="thumbnail">
<div class="intrinsic">
<picture>
<!--[if IE 9]><audio><![endif]-->
<source
data-src="https://images.unsplash.com/photo-1501785888041-af3ef285b470?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&crop=focalpoint&w=550&q=80&ar=1.5:1&fp-x=0.55&fp-y=0.35&fp-z=2"
data-srcset="https://images.unsplash.com/photo-1501785888041-af3ef285b470?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&crop=focalpoint&w=240&q=80&ar=1.5:1&fp-x=0.55&fp-y=0.35&fp-z=2 240w,
https://images.unsplash.com/photo-1501785888041-af3ef285b470?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&crop=focalpoint&w=320&q=80&ar=1.5:1&fp-x=0.55&fp-y=0.35&fp-z=2 320w,
https://images.unsplash.com/photo-1501785888041-af3ef285b470?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&crop=focalpoint&w=500&q=80&ar=1.5:1&fp-x=0.55&fp-y=0.35&fp-z=2 500w"
media="(max-width: 550px)" />
<source
data-src="https://images.unsplash.com/photo-1501785888041-af3ef285b470?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=1024&q=80&ar=1.5:1"
data-srcset="https://images.unsplash.com/photo-1501785888041-af3ef285b470?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&crop=focalpoint&w=640&q=80&ar=1.5:1&fp-x=0.35&fp-y=0.56&fp-z=2 640w,
https://images.unsplash.com/photo-1501785888041-af3ef285b470?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&crop=focalpoint&w=990&q=80&ar=1.5:1&fp-x=0.35&fp-y=0.56&fp-z=2 990w,
https://images.unsplash.com/photo-1501785888041-af3ef285b470?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&crop=focalpoint&w=1024&q=80&ar=1.5:1&fp-x=0.35&fp-y=0.56&fp-z=2 1024w"
media="(max-width: 1024px)" />
<source
data-src="https://images.unsplash.com/photo-1501785888041-af3ef285b470?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=1200&q=80&ar=2:1"
data-srcset="https://images.unsplash.com/photo-1501785888041-af3ef285b470?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=1200&q=80&ar=2:1 1200w" />
<!--[if IE 9]></audio><![endif]-->
<img
class="lazyload"
data-src="https://images.unsplash.com/photo-1501785888041-af3ef285b470?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=1130&q=80&ar=1.5:1 1130w"
src="data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw=="
alt="image with artdirection" />
</picture>
</div>
<div class="caption">
<h3>responsive image with the <code>picture</code> element</h3>
<p>The picture element is also supported. Simply add the <code>lazyload</code> class to the <code>img</code> and use <code>data-srcset</code> on your <code>source</code> and the <code>img</code> element.</p>
<pre><picture>
<!--[if IE 9]><video style="display: none"><![endif]-->
<source
data-srcset="240.jpg 240w,
320.jpg 320w,
500.jpg 500w"
media="(max-width: 550px)" />
<source
data-srcset="640.jpg 640w,
990.jpg 990w,
1024.jpg 1024w"
media="(max-width: 1024px)" />
<source
data-srcset="1200.jpg 1200w" />
<!--[if IE 9]></video><![endif]-->
<img
src="data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw=="
data-src="1024.jpg"
class="lazyload"
alt="image with artdirection" />
</picture>
</pre>
</div>
</div>
</div>
</div>
<div class="row" id="autosizes-example">
<div class="alert alert-info">
<p><strong>automatic sizes feature</strong>: In case of lazy loading images the <code>sizes</code> attribute of the <code>img</code>/<code>source</code> elements can be calculated with JS.</p>
<p>This automatic sizes feature is directly included in <strong>lazySizes</strong>. Simply use the keyword <code>auto</code> inside of the <code>data-sizes</code> attributes (<code>data-sizes="auto"</code>).</p>
<p><strong>Important: How <code>sizes</code> is calculated</strong>: The automatic sizes calculation takes the width of the image if it is over <code>40</code> (see also <code>minSize</code> option). In case it's below the <code>minSize</code> threshold, it traverses up the DOM tree until it finds a parent which is over <code>40</code> and uses this number. Often the following general CSS rule might help: <code>img[data-sizes="auto"] { display: block; }</code>.</p>
</div>
<div class="col-sm-12">
<div class="thumbnail">
<div class="intrinsic">
<img
alt="house by the lake"
data-sizes="auto"
src="https://images.unsplash.com/photo-1470770841072-f978cf4d019e?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&ar=1:1&w=1024"
data-src="https://images.unsplash.com/photo-1470770841072-f978cf4d019e?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&ar=1:1&w=100"
data-srcset="https://images.unsplash.com/photo-1470770841072-f978cf4d019e?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&ar=1:1&w=240 240w,
https://images.unsplash.com/photo-1470770841072-f978cf4d019e?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&ar=1.5:1&w=320 320w,
https://images.unsplash.com/photo-1470770841072-f978cf4d019e?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&ar=1.5:1&w=500 500w,
https://images.unsplash.com/photo-1470770841072-f978cf4d019e?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&ar=1.5:1&w=800 800w,
https://images.unsplash.com/photo-1470770841072-f978cf4d019e?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&ar=1.5:1&w=1024 1024w"
class="lazyload" />
</div>
<div class="caption">
<h3>responsive image with srcset and <strong>automatic sizes</strong> attribute</h3>
<p>The <strong>autosizes feature</strong> makes using responsive images with the right <code>sizes</code> value easy as hell.</p>
<pre><img
alt="house by the lake"
data-sizes="auto"
data-srcset="small.jpg 500w,
medium.jpg 640w,
big.jpg 1024w"
data-src="medium"
class="lazyload" />
</pre>
</div>
</div>
</div>
</div>
<div class="row">
<div class="alert alert-danger">
<p>For responsive images support you must use either use a full polyfill like <a href="https://github.com/scottjehl/picturefill" target="_blank">picturefill</a> or use the <a href="https://github.com/aFarkas/lazysizes/blob/gh-pages/plugins/respimg">extreme lightweight partial respimg polyfill plugin</a> or use the <a href="https://github.com/aFarkas/lazysizes/tree/gh-pages/plugins/rias">Responsive Images as a Service extension</a>.</p>
</div>
</div>
<div class="row">
<div class="col-sm-12">
<div class="thumbnail">
<div class="intrinsic intrinsic-2">
<iframe data-src="//www.youtube.com/embed/ZfV-aYdU4uE" frameborder="0" allowfullscreen="" class="lazyload">
</iframe>
</div>
<div class="caption">
<h3>iframe</h3>
<p>Iframes can be loaded too:</p>
<pre><iframe data-src="//www.youtube.com/embed/ZfV-aYdU4uE" class="lazyload" frameborder="0" allowfullscreen></iframe>
</pre>
</div>
</div>
</div>
</div>
<div class="row lazyload" data-expand="-110">
<div class="col-sm-6">
<div class="thumbnail">
<div class="intrinsic intrinsic-3">
<img
data-sizes="auto"
class="lazyload no-src"
data-src="https://farm1.staticflickr.com/192/504251019_ffc94c77b5_b.jpg"
data-srcset="https://farm1.staticflickr.com/192/504251019_ffc94c77b5_n.jpg 240w,
https://farm1.staticflickr.com/192/504251019_ffc94c77b5.jpg 375w,
https://farm1.staticflickr.com/192/504251019_ffc94c77b5_z.jpg 480w,
https://farm1.staticflickr.com/192/504251019_ffc94c77b5_b.jpg 768w"
alt="Windows on Istanbul" />
</div>
</div>
</div>
<div class="col-sm-6">
<div class="caption">
<h3><code>[data-expand]</code>: More than lazyloading</h3>
<p>LazySizes normally loads in view elements as fast as possible and near the view elements are lazily pre-loaded. This can be modified in general using the <code>expand</code> option. With the <code>data-expand</code> attribute this can be changed element specific to expand or shrink the viewport.</p>
<p>This can be used to create unveiling effects for elements with or even without loading anything.</p>
<pre>
<style>
.teaser.lazyload {
opacity: 0;
transform: scale(0.8);
}
.teaser.lazyloaded {
opacity: 1;
transform: scale(1);
transition: all 700ms;
}
</style>
<script>
window.lazySizesConfig = {
addClasses: true
};
</script>
<div class="teaser lazyload" data-expand="-110">
<img data-src="image.jpg" class="lazyload" />
<h1>Teaser Title</h1>
<p>...</p>
</div>
</pre>
</div>
</div>
</div>
<div class="row">
<div class="col-sm-12">
<div class="thumbnail">
<script src="//code.jquery.com/jquery-2.1.1.min.js"></script>
<div data-ride="carousel" data-script="assets/js/bootstrap.min.js" data-link="assets/css/carousel.css" class="carousel lazyload lazypreload slide no-src" data-interval="false" id="carousel-example-captions">
<ol class="carousel-indicators">
<li data-slide-to="0" data-target="#carousel-example-captions"></li>
<li data-slide-to="1" data-target="#carousel-example-captions"></li>
</ol>
<div class="carousel-inner">
<div class="item">
<div class="intrinsic">
<img alt="100%x200" src="https://i.picsum.photos/id/1031/300/225.jpg"
data-sizes="auto"
data-srcset="https://i.picsum.photos/id/1031/300/225.jpg 300w,
https://i.picsum.photos/id/1031/600/450.jpg 600w,
https://i.picsum.photos/id/1031/1024/768.jpg 1024w,
https://i.picsum.photos/id/1031/1440/1080.jpg 1440w"
class="lazyload" />
</div>
<div class="carousel-caption">
<h3>First slide label</h3>
<p>Nulla vitae elit libero, a pharetra augue mollis interdum.</p>
</div>
</div>
<div class="item active">
<div class="intrinsic">
<img alt="100%x200"
src="https://farm4.staticflickr.com/3059/2835191823_e3636abb34_m.jpg"
data-srcset="https://farm4.staticflickr.com/3059/2835191823_e3636abb34_m.jpg 240w,
https://farm4.staticflickr.com/3059/2835191823_e3636abb34_n.jpg 320w,
https://farm4.staticflickr.com/3059/2835191823_e3636abb34.jpg 500w,
https://farm4.staticflickr.com/3059/2835191823_e3636abb34_z.jpg 640w,
https://farm4.staticflickr.com/3059/2835191823_e3636abb34_b.jpg 1024w"
data-sizes="auto"
class="lazyload" />
</div>
<div class="carousel-caption">
<h3>Third slide label</h3>
<p>Praesent commodo cursus magna, vel scelerisque nisl consectetur.</p>
</div>
</div>
</div>
<a data-slide="prev" role="button" href="#carousel-example-captions" class="left carousel-control">
<span class="glyphicon glyphicon-chevron-left"></span>
</a>
<a data-slide="next" role="button" href="#carousel-example-captions" class="right carousel-control">
<span class="glyphicon glyphicon-chevron-right"></span>
</a>
</div>
<div class="caption">
<h3>Widgets/Javascript/Script</h3>
<p>LazySizes can be extended to load nearly everything lazily. The <a href="https://github.com/aFarkas/lazysizes/tree/gh-pages/plugins">ls.unveilhooks.js</a> plugin can be used to lazy load scripts, background images, and videos. Simply add a <code>data-script</code> to your widget and you are done:</p>
<pre><div data-ride="carousel" data-script="assets/js/bootstrap.min.js" class="carousel lazyload">
<!-- widget content -->
<div>
</pre>
</div>
</div>
</div>
</div>
<div class="row">
<div class="scroll-view">
<div class="scroll-doc">
<div class="scroll-item">
<div class="thumbnail">
<img
data-sizes="auto"
class="lazyload no-src"
src="data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw=="
data-src="https://images.unsplash.com/photo-1470116073782-48ae2ccd8ffd?ixlib=rb-1.2.1&auto=format&fit=crop&w=1024"
data-srcset="https://images.unsplash.com/photo-1470116073782-48ae2ccd8ffd?ixlib=rb-1.2.1&auto=format&fit=crop&w=240 240w,
https://images.unsplash.com/photo-1470116073782-48ae2ccd8ffd?ixlib=rb-1.2.1&auto=format&fit=crop&w=320 320w,
https://images.unsplash.com/photo-1470116073782-48ae2ccd8ffd?ixlib=rb-1.2.1&auto=format&fit=crop&w=500 500w,
https://images.unsplash.com/photo-1470116073782-48ae2ccd8ffd?ixlib=rb-1.2.1&auto=format&fit=crop&w=640 640w,
https://images.unsplash.com/photo-1470116073782-48ae2ccd8ffd?ixlib=rb-1.2.1&auto=format&fit=crop&w=800 800w,
https://images.unsplash.com/photo-1470116073782-48ae2ccd8ffd?ixlib=rb-1.2.1&auto=format&fit=crop&w=1024 1024w"
alt="Bird" />
</div>
</div>
<div class="scroll-item">
<div class="thumbnail">
<img
data-sizes="auto"
class="lazyload no-src"
src="data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw=="
data-src="https://images.unsplash.com/photo-1544198365-f5d60b6d8190?ixlib=rb-1.2.1&auto=format&fit=crop&w=640&q=80"
data-srcset="https://images.unsplash.com/photo-1544198365-f5d60b6d8190?ixlib=rb-1.2.1&auto=format&fit=crop&w=240&q=80 240w,
https://images.unsplash.com/photo-1544198365-f5d60b6d8190?ixlib=rb-1.2.1&auto=format&fit=crop&w=320&q=80 320w,
https://images.unsplash.com/photo-1544198365-f5d60b6d8190?ixlib=rb-1.2.1&auto=format&fit=crop&w=500&q=80 500w,
https://images.unsplash.com/photo-1544198365-f5d60b6d8190?ixlib=rb-1.2.1&auto=format&fit=crop&w=640&q=80 640w"
alt="Mountains" />
</div>
</div>
<div class="scroll-item">
<div class="thumbnail">
<img
data-sizes="auto"
class="lazyload no-src"
src="data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw=="
data-src="https://images.unsplash.com/photo-1523264629844-40dd6bf17c2b?ixlib=rb-1.2.1&auto=format&fit=crop&w=500&q=60"
data-srcset="https://images.unsplash.com/photo-1523264629844-40dd6bf17c2b?ixlib=rb-1.2.1&auto=format&fit=crop&w=240&q=60 240w,
https://images.unsplash.com/photo-1523264629844-40dd6bf17c2b?ixlib=rb-1.2.1&auto=format&fit=crop&w=320&q=60 320w,
https://images.unsplash.com/photo-1523264629844-40dd6bf17c2b?ixlib=rb-1.2.1&auto=format&fit=crop&w=500&q=60 500w"
alt="Jellyfish" />
</div>
</div>
<div class="scroll-item">
<div class="thumbnail">
<img
data-sizes="auto"
class="lazyload no-src"
src="data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw=="
data-src="https://images.unsplash.com/photo-1606041008023-472dfb5e530f?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=500&q=80&ar=1.5:1"
data-srcset="https://images.unsplash.com/photo-1606041008023-472dfb5e530f?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=240&q=80&ar=1.5:1 240w,
https://images.unsplash.com/photo-1606041008023-472dfb5e530f?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=500&q=80&ar=1.5:1 500w"
alt="Flower" />
</div>
</div>
<div class="scroll-item">
<div class="thumbnail">
<img
data-sizes="auto"
class="lazyload no-src"
data-src="https://farm3.staticflickr.com/2401/2171553538_37d0a133da_m.jpg"
src="data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw=="
data-srcset="https://farm3.staticflickr.com/2401/2171553538_37d0a133da_m.jpg 240w,
https://farm3.staticflickr.com/2401/2171553538_37d0a133da.jpg 500w"
alt="Borobudur" />
</div>
</div>
<div class="scroll-item">
<div class="thumbnail">
<img
data-sizes="auto"
class="lazyload no-src"
src="data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw=="
data-src="https://farm1.staticflickr.com/17/92230866_713ae1eeef_n.jpg"
data-srcset="https://farm1.staticflickr.com/17/92230866_713ae1eeef_n.jpg 240w,
https://farm1.staticflickr.com/17/92230866_713ae1eeef.jpg 375w,
https://farm1.staticflickr.com/17/92230866_713ae1eeef_z.jpg 480w"
alt="A tree in the blue" />
</div>
</div>
<div class="scroll-item">
<div class="thumbnail">
<img
data-sizes="auto"
class="lazyload no-src"
src="data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw=="
data-src="https://farm1.staticflickr.com/192/504251019_ffc94c77b5_n.jpg"
data-srcset="https://farm1.staticflickr.com/192/504251019_ffc94c77b5_n.jpg 240w,
https://farm1.staticflickr.com/192/504251019_ffc94c77b5.jpg 375w,
https://farm1.staticflickr.com/192/504251019_ffc94c77b5_z.jpg 480w"
alt="Windows on Istanbul" />
</div>
</div>
<div class="scroll-item">
<div class="thumbnail">
<img
data-sizes="auto"
class="lazyload no-src"
src="data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw=="
data-src="https://farm6.staticflickr.com/5139/5546134597_0b19627066_m.jpg"
data-srcset="https://farm6.staticflickr.com/5139/5546134597_0b19627066_m.jpg 240w,
https://farm6.staticflickr.com/5139/5546134597_0b19627066_n.jpg 320w,
https://farm6.staticflickr.com/5139/5546134597_0b19627066.jpg 500w"
alt="Goldie Dawn" />
</div>
</div>
<div class="scroll-item">
<div class="thumbnail">
<img
data-sizes="auto"
class="lazyload no-src"
src="data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw=="
data-src="https://farm3.staticflickr.com/2727/4393975099_c212622aa0_m.jpg"
data-srcset="https://farm3.staticflickr.com/2727/4393975099_c212622aa0_m.jpg 240w,
https://farm3.staticflickr.com/2727/4393975099_c212622aa0_n.jpg 320w"
alt="Avebury Stone Circle" />
</div>
</div>
<div class="scroll-item">
<div class="thumbnail">
<img
data-sizes="auto"
class="lazyload no-src"
src="data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw=="
data-src="https://farm4.staticflickr.com/3059/2835191823_e3636abb34_m.jpg"
data-srcset="https://farm4.staticflickr.com/3059/2835191823_e3636abb34_m.jpg 240w,
https://farm4.staticflickr.com/3059/2835191823_e3636abb34_n.jpg 320w"
alt="el castil de tierra" />
</div>
</div>
<div class="scroll-item">
<div class="thumbnail">
<img
data-sizes="auto"
class="lazyload no-src"
src="data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw=="
data-src="https://farm8.staticflickr.com/7356/11122919374_55294abec3_m.jpg"
data-srcset="https://farm8.staticflickr.com/7356/11122919374_55294abec3_m.jpg 240w,
https://farm8.staticflickr.com/7356/11122919374_55294abec3_n.jpg 320w,
https://farm8.staticflickr.com/7356/11122919374_55294abec3.jpg 500w"
alt="sunset" />
</div>
</div>
<div class="scroll-item">
<div class="thumbnail">
<img
data-sizes="auto"
class="lazyload no-src"
src="data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw=="
data-src="https://farm6.staticflickr.com/5506/11122805655_e63cb3a9fc_m.jpg"
data-srcset="https://farm6.staticflickr.com/5506/11122805655_e63cb3a9fc_m.jpg 240w,
https://farm6.staticflickr.com/5506/11122805655_e63cb3a9fc_n.jpg 320w,
https://farm6.staticflickr.com/5506/11122805655_e63cb3a9fc.jpg 500w"
alt="Sky and earth" />
</div>
</div>
<div class="scroll-item">
<div class="thumbnail">
<img
data-sizes="auto"
class="lazyload no-src"
src="data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw=="
data-src="https://farm4.staticflickr.com/3023/2994603808_a3036a3cdf_n.jpg"
data-srcset="https://farm4.staticflickr.com/3023/2994603808_a3036a3cdf_n.jpg 240w,
https://farm4.staticflickr.com/3023/2994603808_a3036a3cdf.jpg 375w,
https://farm4.staticflickr.com/3023/2994603808_a3036a3cdf_z.jpg 480w"
alt="Missing Ulsoor lake (Explore)" />
</div>
</div>
<div class="scroll-item">
<div class="thumbnail">
<img
data-sizes="auto"
class="lazyload"
src="https://farm7.staticflickr.com/6211/6254520191_c7868f3a5d_n.jpg"
data-src="https://farm7.staticflickr.com/6211/6254520191_c7868f3a5d_n.jpg"
data-srcset="https://farm7.staticflickr.com/6211/6254520191_c7868f3a5d_n.jpg 227w,
https://farm7.staticflickr.com/6211/6254520191_c7868f3a5d.jpg 354w,
https://farm7.staticflickr.com/6211/6254520191_c7868f3a5d_z.jpg 453w"
alt="Oxford Path 2" />
</div>
</div>
</div>
</div>
</div>
<div class="row">
<div class="alert alert-info">
<p>While other lazy loaders or responsive images solution need to be called, if new elements are added to the DOM or do become visible through a special user interaction or a JavaScript behavior.</p>
<p>LazySizes does automatically detect any changes to the DOM and the visibility of <code>.lazyload</code> elements.</p>
<button type="button" class="add-new btn btn-primary">click to add new elements</button>
</div>
<script type="text/html" class="template">
<div class="row">
<div class="thumbnail thumbnail-small lazyload" data-expand="-40">
<div class="intrinsic">
<img
class="lazyload no-src"
data-src="https://i.picsum.photos/id/1031/460/345.jpg"
alt="" />
</div>
</div>
<div class="thumbnail thumbnail-small lazyload" data-expand="-40">
<div class="intrinsic">
<img
class="lazyload no-src"
data-src="https://i.picsum.photos/id/1059/460/345.jpg"
alt="" />
</div>
</div>
<div class="thumbnail thumbnail-small lazyload" data-expand="-40">
<div class="intrinsic">
<img
class="lazyload no-src"
data-src="https://i.picsum.photos/id/1062/460/345.jpg"
alt="" />
</div>
</div>
</div>
<div class="row effect-row">
<div class="thumbnail thumbnail-small lazyload lightSpeedIn" data-expand="-40">
<div class="intrinsic">
<img
class="lazyload no-src"
data-src="https://i.picsum.photos/id/1065/460/345.jpg"
alt="" />
</div>
</div>
<div class="thumbnail thumbnail-small lazyload lightSpeedIn" data-expand="-40">
<div class="intrinsic">
<img
class="lazyload no-src"
data-src="https://i.picsum.photos/id/1069/460/345.jpg"
alt="" />
</div>
</div>
<div class="thumbnail thumbnail-small lazyload lightSpeedIn" data-expand="-40">
<div class="intrinsic">
<img
class="lazyload no-src"
data-src="https://i.picsum.photos/id/1072/460/345.jpg"
alt="" />
</div>
</div>
</div>
<div class="row effect-row-middle">
<div class="thumbnail thumbnail-small lazyload" data-expand="-40">
<div class="intrinsic">
<img
class="lazyload no-src"
data-src="https://i.picsum.photos/id/1074/460/345.jpg"
alt="" />
</div>
</div>
<div class="thumbnail thumbnail-small lazyload" data-expand="-40">
<div class="intrinsic">
<img
class="lazyload no-src"
data-src="https://i.picsum.photos/id/110/460/345.jpg"
alt="" />
</div>
</div>
<div class="thumbnail thumbnail-small lazyload" data-expand="-40">
<div class="intrinsic">
<img
class="lazyload no-src"
data-src="https://i.picsum.photos/id/111/460/345.jpg"
alt="" />
</div>
</div>
</div>
<div class="row effect-row-reverse">
<div class="thumbnail thumbnail-small lazyload flipInX" data-expand="-40">
<div class="intrinsic">
<img
class="lazyload no-src"
data-src="https://i.picsum.photos/id/116/460/345.jpg"
alt="" />
</div>
</div>
<div class="thumbnail thumbnail-small lazyload flipInX" data-expand="-40">
<div class="intrinsic">
<img
class="lazyload no-src"
data-src="https://i.picsum.photos/id/122/460/345.jpg"
alt="" />
</div>
</div>
<div class="thumbnail thumbnail-small lazyload flipInX" data-expand="-40">
<div class="intrinsic">
<img
class="lazyload no-src"
data-src="https://i.picsum.photos/id/1031/460/345.jpg"
alt="" />
</div>
</div>
</div>
<div class="row">
<div class="thumbnail thumbnail-small lazyload" data-expand="-40">
<div class="intrinsic">
<img
class="lazyload no-src"
data-src="https://i.picsum.photos/id/134/460/345.jpg"
alt="" />
</div>
</div>
<div class="thumbnail thumbnail-small lazyload" data-expand="-40">
<div class="intrinsic">
<img
class="lazyload no-src"
data-src="https://i.picsum.photos/id/133/460/345.jpg"
alt="" />
</div>
</div>
<div class="thumbnail thumbnail-small lazyload" data-expand="-40">
<div class="intrinsic">
<img
class="lazyload no-src"
data-src="https://i.picsum.photos/id/137/460/345.jpg"
alt="" />
</div>
</div>
</div>
</script>
<script>
$('.add-new').on('click', function(){
var $template = $('.template');
$template.after($template.html());
});
</script>
<br />
<br />
<br />
<br />
<br />
<br />
</div>
</div>
</div>
</body>
</html>