Skip to content

Commit

Permalink
lazyload images: pr zedeus#1157 zedeus/nitter
Browse files Browse the repository at this point in the history
  • Loading branch information
alnmy committed Feb 26, 2024
1 parent 1322d13 commit 87b836e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/views/renderutils.nim
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ proc genDate*(pref, state: string): VNode =

proc genImg*(url: string; class=""): VNode =
buildHtml():
img(src=getPicUrl(url), class=class, alt="")
img(src=getPicUrl(url), class=class, loading="lazy", alt="")

proc getTabClass*(query: Query; tab: QueryKind): string =
if query.kind == tab: "tab-item active"
Expand Down
8 changes: 4 additions & 4 deletions src/views/tweet.nim
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const doctype = "<!DOCTYPE html>\n"
proc renderMiniAvatar(user: User; prefs: Prefs): VNode =
let url = getPicUrl(user.getUserPic("_mini"))
buildHtml():
img(class=(prefs.getAvatarClass & " mini"), src=url)
img(class=(prefs.getAvatarClass & " mini"), src=url, loading="lazy")

proc renderHeader(tweet: Tweet; retweet: string; pinned: bool; prefs: Prefs): VNode =
buildHtml(tdiv):
Expand Down Expand Up @@ -92,10 +92,10 @@ proc renderVideo*(video: Video; prefs: Prefs; path: string): VNode =
tdiv(class="attachment video-container"):
let thumb = getSmallPic(video.thumb)
if not video.available:
img(src=thumb)
img(src=thumb, loading="lazy")
renderVideoUnavailable(video)
elif not prefs.isPlaybackEnabled(playbackType):
img(src=thumb)
img(src=thumb, loading="lazy")
renderVideoDisabled(playbackType, path)
else:
let
Expand Down Expand Up @@ -144,7 +144,7 @@ proc renderPoll(poll: Poll): VNode =
proc renderCardImage(card: Card): VNode =
buildHtml(tdiv(class="card-image-container")):
tdiv(class="card-image"):
img(src=getPicUrl(card.image), alt="")
img(src=getPicUrl(card.image), alt="", loading="lazy")
if card.kind == player:
tdiv(class="card-overlay"):
tdiv(class="overlay-circle"):
Expand Down

0 comments on commit 87b836e

Please sign in to comment.