Skip to content

Commit c510394

Browse files
authored
Use YT JS-based lazy-load (#89)
1 parent 03e45b6 commit c510394

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

_includes/layout/footer.html

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
$('pre code').each(function(i, e) {hljs.highlightBlock(e)});
2929
});
3030
</script>
31-
<script>
31+
<script type="text/javascript">
3232
$(function() {
3333
$(".dropdown").hover(
3434
function(){ $(this).addClass('open') },
@@ -42,3 +42,12 @@
4242
);
4343
});
4444
</script>
45+
<script type="text/javascript">
46+
function init() {
47+
var vidDefer = document.getElementsByTagName('iframe');
48+
for (var i=0; i<vidDefer.length; i++) {
49+
if(vidDefer[i].getAttribute('data-src')) {
50+
vidDefer[i].setAttribute('src',vidDefer[i].getAttribute('data-src'));
51+
} } }
52+
window.onload = init;
53+
</script>

index.html

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -206,9 +206,8 @@ <h2>
206206
Watch the Presentation
207207
</h2>
208208
<div class="embed-responsive embed-responsive-16by9">
209-
<iframe class="embed-responsive-item" width="560" height="315" src="https://www.youtube.com/embed/iQU18hAjux4"
209+
<iframe class="embed-responsive-item" width="560" height="315" src="" data-src="https://www.youtube.com/embed/iQU18hAjux4"
210210
title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share"
211-
loading="lazy"
212211
allowfullscreen></iframe>
213212
</div>
214213
</div>

0 commit comments

Comments
 (0)