File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 6464 < script src ="https://cdn.jsdelivr.net/npm/bootstrap@4.0.0/dist/js/bootstrap.min.js "
6565 integrity ="sha256-5+02zu5UULQkO7w1GIr6vftCgMfFdZcAHeDtFnKZsBs= " crossorigin ="anonymous "> </ script >
6666
67+ < script type ="text/javascript " src ="https://cdn.jsdelivr.net/npm/lozad/dist/lozad.min.js "> </ script >
68+
6769 < script src ="{{ site.baseurl }}/assets/js/dist/commons.js " async > </ script >
6870
6971 {% if jekyll.environment == 'production' %}
Original file line number Diff line number Diff line change @@ -42,12 +42,21 @@ <h1 data-toc-skip>{{ page.title }}</h1>
4242 {% endif %}
4343 </ div > <!-- .post-meta -->
4444
45+ {% capture post_content %}
4546 < div class ="post-content ">
4647 {% if page.image %}
4748 < img src ="{{ page.image }} " class ="img-rounded ">
4849 {% endif %}
4950 {{ content }}
50- </ div > <!-- .post-content -->
51+ </ div >
52+ {% endcapture %}
53+
54+ <!-- Add lozad class into image tags. see: <https://github.com/ApoorvSaxena/lozad.js#usage> -->
55+ {% if post_content contains '< img src =' %}
56+ {{ post_content | replace: '< img src =', '< img class ="lozad " data-src =' }}
57+ {% else %}
58+ {{ post_content }}
59+ {% endif %}
5160
5261 <div class="post-tail text-muted">
5362 <!-- Tags -->
@@ -97,3 +106,9 @@ <h1 data-toc-skip>{{ page.title }}</h1>
97106</ div > <!-- div.col-12..col-lg-11.col-xl-8 -->
98107
99108{% include panel.html %}
109+
110+ <!-- image lazy load -->
111+ < script type ="text/javascript ">
112+ const observer = lozad ( ) ;
113+ observer . observe ( ) ;
114+ </ script >
You can’t perform that action at this time.
0 commit comments