@@ -27,34 +27,37 @@ new dll('selector',callback);
2727# Works with
2828Any valid selector or no selector.
2929``` js
30- new dll (' .uniqueClassName' ); // lazy loads an element with a given class and it's children if any have data-src
30+ // lazy loads an element with a given class and it's children if any have data-src
31+ new dll (' .uniqueClassName' );
3132
32- new dll (' #uniqueID' ); // lazy loads an element with a given ID and it's children if any have data-src
33+ // lazy loads an element with a given ID and it's children if any have data-src
34+ new dll (' #uniqueID' );
3335
34- new dll (); // lazy loads any items with data-src from the entire page
36+ // lazy loads any items with data-src from the entire page
37+ new dll ();
3538```
3639
3740# Other examples
3841If your script is in your site head, you should do this
3942``` js
40- window .addEventListener (' load' , loadFunctionExample, false );
4143function loadFunctionExample (){
4244 new dll (' [data-src]' , myFunction);
4345}
46+ window .addEventListener (' load' , loadFunctionExample, false );
4447```
4548
4649If you want to lazy load on scroll
4750``` js
48- window .addEventListener (' scroll' , scrollExample, false );
49- function scrollExample (){
50- var el = document .getElementById (' myItem' );
51- if ( elementInViewport (el) ){
52- new dll (el, callback)
53- }
54- function callback (){
55- // do some stuff when loading finished
56- }
51+ function scrollExample (){
52+ var el = document .getElementById (' myItem' );
53+ if ( elementInViewport (el) ){
54+ new dll (el, callback)
5755 }
56+ function callback (){
57+ // do some stuff when loading finished
58+ }
59+ }
60+ window .addEventListener (' scroll' , scrollExample, false );
5861```
5962
6063# A nasty example
0 commit comments