diff options
context:
space:
mode:
authorBryce Kwon <bryce@brycekwon.com>
committerBryce Kwon <bryce@brycekwon.com>
commit
parent
tree
download
Lazy load the avatar icons
Diffstat (limited to 'custom/extensions/email-gravatar.lua')
-rw-r--r--custom/extensions/email-gravatar.lua6
1 file changed, 5 insertions, 1 deletion
diff --git a/custom/extensions/email-gravatar.lua b/custom/extensions/email-gravatar.lua
index 6ce688f..3204ef1 100644
--- a/custom/extensions/email-gravatar.lua
+++ b/custom/extensions/email-gravatar.lua
@@ -95,6 +95,9 @@ function filter_write(text)
buffer = buffer .. text
end
+-- A log page can carry one icon per commit, so the attributes let the
+-- browser defer the fetches for icons still off screen and keep decoding
+-- off the critical path.
function filter_close()
if avatar_hash == nil then
html(buffer)
@@ -104,7 +107,8 @@ function filter_close()
"&amp;d=" .. default_image ..
"' width='" .. avatar_size ..
"' height='" .. avatar_size ..
- "' alt='" .. alt_text .. "' /> " .. buffer)
+ "' loading='lazy' decoding='async'" ..
+ " alt='" .. alt_text .. "'> " .. buffer)
end
return 0
end