Debian Codegraph @

example/index.html

raw
1 <!DOCTYPE html>
2 <html class="no-js">
3 <head>
4 <meta charset="utf-8">
5 <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
6 <title>blazy.js - lazyload examples</title>
7 <meta name="viewport" content="width=device-width, initial-scale=1">
8 <style> html,body,div,span,applet,object,iframe,h1,h2,h3,h4,h5,h6,p,blockquote,pre,a,abbr,acronym,address,big,cite,code,del,dfn,em,img,ins,kbd,q,s,samp,small,strike,strong,sub,sup,tt,var,b,u,i,center,dl,dt,dd,ol,ul,li,fieldset,form,label,legend,table,caption,tbody,tfoot,thead,tr,th,td,article,aside,canvas,details,embed,figure,figcaption,footer,header,hgroup,menu,nav,output,ruby,section,summary,time,mark,audio,video{margin:0;padding:0;border:0;font-size:100%;font:inherit;vertical-align:baseline}article,aside,details,figcaption,figure,footer,header,hgroup,menu,nav,section{display:block}body{line-height:1}ul{list-style:none}blockquote,q{quotes:none}blockquote:before,blockquote:after,q:before,q:after{content:'';content:none}table{border-collapse:collapse;border-spacing:0}
9 body {
10 font-family: "Helvetica Neue",Helvetica,Arial,sans-serif;
11 }
12 h1 {
13 font-size: 75px;
14 font-weight: bold;
15 }
16 h2 {
17 font-size:40px;
18 padding: 20px 0 10px;
19 }
20 p{
21 padding:10px 0;
22 }
23 li{
24 padding: 3px 0;
25 }
26 .ratio{
27 padding-bottom:66.64%;
28 background-color: #1E1E1E;
29 height: 0;
30 width: 100%;
31 overflow: hidden;
32 position: relative;
33 }
34 .example {
35 overflow:hidden;
36 position:relative;
37 }
38 .example iframe {
39 position:absolute;
40 height:100%;
41 width:100%;
42 }
43 .header {
44 background: #ececec;
45 padding: 50px;
46 color: black;
47 }
48 .branding{
49 max-width: 900px;
50 margin: 0 auto;
51 }
52 .branding pre{
53 background: #f7f7f7;
54 color: black;
55 border-radius: 0;
56 }
57 .github {
58 background: url('http://dinbror.dk/blazy/assets/github.png') 0 0 no-repeat;
59 height: 149px;
60 width: 149px;
61 position: absolute;
62 top: 0;
63 right: 0;
64 }
65 .section {
66 margin: 0 auto;
67 max-width:900px;
68 }
69 .container {
70 background-color: #1E1E1E;
71 height:0;
72 padding-bottom:66%;
73 }
74 .horizontal.container{
75 overflow-x: scroll;
76 overflow-y: hidden;
77 }
78 .horizontal .list{
79 font-size:0;
80 width:300%;
81 }
82 .horizontal .list .wrapper {
83 display: inline-block;
84 width:33.3%;
85 }
86 .vertical.container{
87 overflow-x: hidden;
88 overflow-y: scroll;
89 }
90 .vertical .list{
91 width: 100%;
92 }
93 .vertical .list .wrapper{
94 width: 100%;
95 }
96 img {
97 max-width: 100%;
98 }
99 pre {
100 background: #212121;
101 color: white;
102 padding: 15px 10px 5px;
103 margin: 0 0 20px;
104 font-family:Menlo,monospace;
105 font-size: 14px;
106 overflow-x: auto;
107 }
108 .b-lazy, video{
109 display:inline-block;
110 position:absolute;
111 left:0;
112 top:0;
113 height:100%;
114 width:100%;
115 }
116 .list .b-lazy{
117 max-height:100%;
118 height:auto;
119 }
120 .b-lazy.animate{
121 opacity:0;
122 -ms-transform: scale(3);
123 -moz-transform: scale(3);
124 -webkit-transform: scale(3);
125 transform: scale(3);
126 -ms-transition: all 500ms;
127 -moz-transition: all 500ms;
128 -webkit-transition: all 500ms;
129 transition: all 500ms;
130 }
131 .b-loaded.animate {
132 opacity:1;
133 -ms-transform: scale(1);
134 -moz-transform: scale(1);
135 -webkit-transform: scale(1);
136 transform: scale(1);
137 }
138
139 @media (max-width: 600px) {
140 h1 {
141 font-size: 40px;
142 }
143 h2 {
144 font-size: 25px;
145 }
146 }
147 </style>
148 </head>
149 <body>
150 <div class="header">
151 <div class="branding">
152 <h1>blazy.js</h1>
153 <p>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.</p>
154 <p>Blazy comes with a bunch of features like serving retina images for retina screens, multi-serve images depending on screensize and error handling. <a href="http://dinbror.dk/blog/blazy/?ref=example-page">For a list of all features and more details you can visit the blog post</a>. Blazy works in all modern browsers including IE7+.</p>
155 <h2>How to lazyload</h2>
156 <ol>
157 <li>Add blazy.js to your website</li>
158 <li>Add the 'b-lazy' class to the elements that should be lazy loaded</li>
159 <li>Initialize blazy whenever you're ready <br><br>
160 <pre>
161 var bLazy = new Blazy({
162 // Options
163 });
164 </pre>
165 </li>
166 </ol>
167 <h2>Examples</h2>
168 <ol>
169 <li><a href="#image">Lazy load images, regular, retina, srcset and picture element</a></li>
170 <li><a href="#background-image">Lazy load background image</a></li>
171 <li><a href="#image-inside-container">Lazy load inside container (vertical & horizotal)</a></li>
172 <li><a href="#iframe">Lazy load iframe</a></li>
173 <li><a href="#html5-video">Lazy load HTML5 video</a></li>
174 <li><a href="#script">Lazy load script file</a></li>
175 </ol>
176 </div>
177 <a class="github" href="https://github.com/dinbror/blazy/"></a>
178 </div>
179 <div class="section">
180 <div class="example" id="image">
181 <h2>1.1: Default lazyload image example</h2>
182 <div class="wrapper ratio">
183 <img class="b-lazy" src=data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw== data-src="http://cdn.dinbror.dk/assets/blazy/01.jpg" alt="Lazy load images example 1a" />
184 </div>
185 <pre>
186 &lt;img class="b-lazy" data-src=&quot;image.jpg&quot; /&gt;
187 </pre>
188 </div>
189 <div class="example">
190 <h2>1.2: Lazy load image example with css effect</h2>
191 <div class="wrapper ratio">
192 <img class="b-lazy animate" src=data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw== data-src="http://cdn.dinbror.dk/assets/blazy/02.jpg" alt="Lazy load images example 1b" />
193 </div>
194 <pre>
195 CSS:
196
197 .b-lazy {
198 opacity:0;
199 transform: scale(3);
200 transition: all 500ms;
201 }
202 .b-loaded {
203 opacity:1;
204 transform: scale(1);
205 }
206 </pre>
207 </div>
208 <div class="example">
209 <h2>1.3: Lazy load image example with low res image placeholder</h2>
210 <div class="wrapper ratio">
211 <img class="b-lazy" src="http://cdn.dinbror.dk/assets/blazy/03-low.jpg" data-src="http://cdn.dinbror.dk/assets/blazy/03.jpg" alt="Lazy load images example 1c" />
212 </div>
213 <pre>
214 &lt;img class="b-lazy" src=&quot;low-res-image.jpg&quot; data-src=&quot;image.jpg&quot; /&gt;
215 </pre>
216 </div>
217 <div class="example">
218 <h2>1.4: Lazy load image example with srcset</h2>
219 <div class="wrapper ratio">
220 <img
221 alt="Lazy load image example with srcset"
222 sizes="100vw"
223 data-srcset="http://placehold.it/1024x682?text=large 1024w,
224 http://placehold.it/600x400?text=medium 640w,
225 http://placehold.it/320x214?text=small 320w"
226 data-src="http://placehold.it/600x400?text=fallback"
227 class="b-lazy" />
228 </div>
229 <pre>
230 &lt;img class="b-lazy"
231 sizes=&quot;100vw&quot;
232 data-srcset=&quot;large.jpg 1024w, medium.jpg 640w, small.jpg 320w&quot;
233 data-src=&quot;medium.jpg&quot; /&gt;
234 </pre>
235 </div>
236 <div class="example">
237 <h2>1.5: Lazy load image example with picture element</h2>
238 <div class="wrapper ratio">
239 <picture>
240 <source
241 media="(min-width: 650px)"
242 data-srcset="http://placehold.it/1024x682?text=Min-650" />
243 <source
244 media="(min-width: 465px)"
245 data-srcset="http://placehold.it/600x400?text=Min-465" />
246 <img
247 class="b-lazy"
248 data-src="http://placehold.it/600x400?text=default"
249 alt="Lazy load image example with picture element" />
250 </picture>
251 </div>
252 <pre>
253 &lt;picture&gt;
254 &lt;source
255 media=&quot;(min-width: 650px)&quot;
256 data-srcset=&quot;image-650.jpg&quot; /&gt;
257 &lt;source
258 media=&quot;(min-width: 465px)&quot;
259 data-srcset=&quot;image-465.jpg&quot; /&gt;
260 &lt;img class=&quot;b-lazy&quot;
261 data-src=&quot;default.jpg&quot; /&gt;
262 &lt;/picture&gt;
263 </pre>
264 </div>
265 <div class="example">
266 <h2>1.6: Lazyload image with retina support example</h2>
267 <div class="wrapper ratio">
268 <img class="b-lazy" src=data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw== data-src="http://placehold.it/1024x682?text=Non-Retina|http://placehold.it/1024x682?text=Retina" alt="Lazy load images example 1a" />
269 </div>
270 <pre>
271 &lt;img class="b-lazy" data-src=&quot;image.jpg|retina-image.jpg&quot; /&gt;
272 </pre>
273 </div>
274 <div class="example" id="background-image">
275 <h2>2: Lazy load background image example</h2>
276 <div class="wrapper ratio">
277 <div class="b-lazy" data-src="http://cdn.dinbror.dk/assets/blazy/05.jpg"></div>
278 </div>
279 <pre>
280 &lt;div class="b-lazy" data-src=&quot;image.jpg&quot;&gt;&lt;/div&gt;
281 </pre>
282 </div>
283 <div class="example" id="image-inside-container">
284 <h2>3.1: Horizontal lazyload inside container example</h2>
285 <div class="container horizontal">
286 <ul class="list">
287 <li class="wrapper ratio">
288 <img class="b-lazy" src=data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw== data-src="http://cdn.dinbror.dk/assets/blazy/04.jpg" alt="Lazy load images example 3 image 1" />
289 </li>
290 <li class="wrapper ratio">
291 <img class="b-lazy" src=data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw== data-src="http://cdn.dinbror.dk/assets/blazy/05.jpg" alt="Lazy load images example 3 image 2" />
292 </li>
293 <li class="wrapper ratio">
294 <img class="b-lazy" src=data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw== data-src="http://cdn.dinbror.dk/assets/blazy/06.jpg" alt="Lazy load images example 3 image 3" />
295 </li>
296 </ul>
297 </div>
298 <pre>
299 var blazy = new Blazy({
300 container: '.container'
301 });
302 </pre>
303 </div>
304 <div class="example">
305 <h2>3.2: Vertical lazyload inside container example</h2>
306 <div class="container vertical">
307 <ul class="list">
308 <li class="wrapper ratio">
309 <img class="b-lazy" src=data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw== data-src="http://cdn.dinbror.dk/assets/blazy/04.jpg" alt="Lazy load images example 3 image 1" />
310 </li>
311 <li class="wrapper ratio">
312 <img class="b-lazy" src=data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw== data-src="http://cdn.dinbror.dk/assets/blazy/05.jpg" alt="Lazy load images example 3 image 2" />
313 </li>
314 <li class="wrapper ratio">
315 <img class="b-lazy" src=data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw== data-src="http://cdn.dinbror.dk/assets/blazy/06.jpg" alt="Lazy load images example 3 image 3" />
316 </li>
317 </ul>
318 </div>
319 <pre>
320 var blazy = new Blazy({
321 container: '.container'
322 });
323 </pre>
324 </div>
325 <div class="example" id="iframe">
326 <h2>4: Lazy load iframe example</h2>
327 <div class="wrapper ratio">
328 <iframe class="b-lazy" data-src="https://www.youtube.com/embed/uKtjVQ5IJOQ" frameborder="0" allowfullscreen></iframe>
329 </div>
330 <pre>
331 &lt;iframe class=&quot;b-lazy&quot;
332 data-src=&quot;https://www.youtube.com/embed/uKtjVQ5IJOQ&quot;
333 frameborder=&quot;0&quot;
334 allowfullscreen>
335 &lt;/iframe&gt;
336 </pre>
337 </div>
338 <div class="example" id="html5-video">
339 <h2>5.1: Lazy load HTML5 video example</h2>
340 <div class="wrapper ratio">
341 <video class="b-lazy" data-src="http://cdn.dinbror.dk/assets/blazy/SampleVideo_1280x720_1mb.mp4" controls></video>
342 </div>
343 <pre>
344 &lt;video class="b-lazy" data-src=&quot;video.mp4&quot; controls&gt;&lt;/video&gt;
345 </pre>
346 </div>
347 <div class="example">
348 <h2>5.2: Lazy load HTML5 video advanced example</h2>
349 <div class="wrapper ratio">
350 <video class="b-lazy" controls>
351 <source data-src="http://cdn.dinbror.dk/assets/blazy/big_buck_bunny.mp4" type="video/mp4">
352 <source data-src="http://cdn.dinbror.dk/assets/blazy/big_buck_bunny.webm" type="video/webm">
353 Your browser doesn't support HTML5 video tag.
354 </video>
355 </div>
356 <pre>
357 &lt;video class="b-lazy" controls&gt;
358 &lt;source data-src=&quot;video.mp4&quot; type=&quot;video/mp4&quot;&gt;
359 &lt;source data-src=&quot;video.webm&quot; type=&quot;video/webm&quot;&gt;
360 Your browser doesn&#39;t support HTML5 video tag.
361 &lt;/video&gt;
362 </pre>
363 </div>
364 <div class="example" id="script">
365 <h2>6: Lazy load script example</h2>
366 <script class="b-lazy" data-src="script.js" async></script>
367 <p>Check the console log</p>
368 <pre>
369 &lt;script class="b-lazy" data-src=&quot;script.js&quot; async&gt;&lt;/script&gt;
370 </pre>
371 </div>
372 </div>
373 <script src="../polyfills/closest.js"></script>
374 <script src="../blazy.js"></script>
375 <script>
376 window.bLazy = new Blazy({
377 container: '.container',
378 success: function(element){
379 console.log("Element loaded: ", element.nodeName);
380 }
381 });
382 </script>
383 </body>
384 </html>