Lazy load iframe

This commit is contained in:
cuom1999 2022-11-09 14:53:55 -06:00
parent f6b16a30ac
commit 7150718a51
2 changed files with 9 additions and 1 deletions

View file

@ -85,5 +85,10 @@ def markdown(value, lazy_load=False):
if img.get("src"): if img.get("src"):
img["data-src"] = img["src"] img["data-src"] = img["src"]
img["src"] = "" img["src"] = ""
for img in soup.findAll("iframe"):
if img.get("src"):
img["data-src"] = img["src"]
img["src"] = ""
html = str(soup) html = str(soup)
return '<div class="md-typeset">%s</div>' % html return '<div class="md-typeset">%s</div>' % html

View file

@ -179,7 +179,10 @@ $(function () {
$("[data-src]img").each(function() { $("[data-src]img").each(function() {
$(this).attr("src", $(this).attr("data-src")); $(this).attr("src", $(this).attr("data-src"));
}) })
}, "500"); $("[data-src]iframe").each(function() {
$(this).attr("src", $(this).attr("data-src"));
})
}, "100");
}); });
if (!Date.now) { if (!Date.now) {