Set loading=lazy on images.

This commit is contained in:
Ethan Dalool 2020-11-04 16:31:08 -08:00
parent 137f75c42d
commit c76bfec549

View file

@ -599,6 +599,11 @@ def inject_footnotes(soup):
for link in links:
link['title'] = texts[link['data-index']]
def set_img_lazyload(soup):
imgs = soup.find_all('img')
for img in imgs:
img['loading'] = 'lazy'
# FINAL MARKDOWNS
################################################################################
def markdown(
@ -639,6 +644,7 @@ def markdown(
fix_classes(soup)
fix_reddit_links(soup)
inject_footnotes(soup)
set_img_lazyload(soup)
if do_embed_images:
embed_images(soup, cache=image_cache)