Skip to content

Commit 442ff5d

Browse files
authored
Add fetchpriority attribute to main book cover image (#11444)
* Add fetchpriority attribute to main book cover image * Fix syntax for conditional preload attribute * Add fetchpriority to preload metatag for cover image Apparently "Important: When preloading the image, ensure fetchpriority=high is set on the preload as well as the image." https://developer.chrome.com/docs/performance/insights/lcp-discovery
1 parent f93e42d commit 442ff5d

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

openlibrary/templates/covers/book_cover.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
$ srcset = '%s 2x' % (cover_lg or '/images/icons/avatar_book-lg.png')
1717

1818
$if preload:
19-
$add_metatag(tag="link", **{'rel': 'preload', 'as': 'image', 'href': src, 'imagesrcset': srcset})
19+
$add_metatag(tag="link", **{'rel': 'preload', 'as': 'image', 'href': src, 'imagesrcset': srcset, 'fetchpriority': 'high'})
2020

2121
<div class="coverMagic cover-animation">
2222
<div class="SRPCover bookCover" style="display: $cond(cover_url, 'block', 'none');">
@@ -34,6 +34,7 @@
3434
class="cover"
3535
style="$cover_aspect_ratio_str"
3636
alt="$_('Cover of: %(title)s by %(authors)s', title=title, authors=author_names)"
37+
$:cond(preload, 'fetchpriority="high"', '')
3738
>
3839
</a>
3940
</div>

0 commit comments

Comments
 (0)