Time to try fetchPriority=low

This commit is contained in:
Lim Chee Aun 2024-10-11 02:11:08 +08:00
parent edd34a5cfe
commit 48537742a2
5 changed files with 32 additions and 28 deletions

View file

@ -50,6 +50,7 @@ function Avatar({ url, size, alt = '', squircle, ...props }) {
alt={alt} alt={alt}
loading="lazy" loading="lazy"
decoding="async" decoding="async"
fetchPriority="low"
crossOrigin={ crossOrigin={
alphaCache[url] === undefined && !isMissing alphaCache[url] === undefined && !isMissing
? 'anonymous' ? 'anonymous'

View file

@ -13,6 +13,7 @@ export default function CustomEmoji({ staticUrl, alt, url }) {
height="16" height="16"
loading="lazy" loading="lazy"
decoding="async" decoding="async"
fetchPriority="low"
/> />
</picture> </picture>
); );

View file

@ -2788,6 +2788,8 @@ function Card({ card, selfReferential, selfAuthor, instance }) {
width={width} width={width}
height={height} height={height}
loading="lazy" loading="lazy"
decoding="async"
fetchPriority="low"
alt={imageDescription || ''} alt={imageDescription || ''}
onError={(e) => { onError={(e) => {
try { try {

54
src/locales/en.po generated
View file

@ -289,7 +289,7 @@ msgstr ""
#: src/components/account-info.jsx:1308 #: src/components/account-info.jsx:1308
#: src/components/shortcuts-settings.jsx:1056 #: src/components/shortcuts-settings.jsx:1056
#: src/components/status.jsx:1152 #: src/components/status.jsx:1152
#: src/components/status.jsx:3217 #: src/components/status.jsx:3219
msgid "Copy" msgid "Copy"
msgstr "" msgstr ""
@ -417,9 +417,9 @@ msgstr ""
#: src/components/shortcuts-settings.jsx:227 #: src/components/shortcuts-settings.jsx:227
#: src/components/shortcuts-settings.jsx:580 #: src/components/shortcuts-settings.jsx:580
#: src/components/shortcuts-settings.jsx:780 #: src/components/shortcuts-settings.jsx:780
#: src/components/status.jsx:2942 #: src/components/status.jsx:2944
#: src/components/status.jsx:3181 #: src/components/status.jsx:3183
#: src/components/status.jsx:3679 #: src/components/status.jsx:3681
#: src/pages/accounts.jsx:36 #: src/pages/accounts.jsx:36
#: src/pages/catchup.jsx:1581 #: src/pages/catchup.jsx:1581
#: src/pages/filters.jsx:224 #: src/pages/filters.jsx:224
@ -1207,9 +1207,9 @@ msgid "Filtered: {filterTitleStr}"
msgstr "" msgstr ""
#: src/components/media-post.jsx:133 #: src/components/media-post.jsx:133
#: src/components/status.jsx:3509 #: src/components/status.jsx:3511
#: src/components/status.jsx:3605 #: src/components/status.jsx:3607
#: src/components/status.jsx:3683 #: src/components/status.jsx:3685
#: src/components/timeline.jsx:973 #: src/components/timeline.jsx:973
#: src/pages/catchup.jsx:75 #: src/pages/catchup.jsx:75
#: src/pages/catchup.jsx:1876 #: src/pages/catchup.jsx:1876
@ -2094,7 +2094,7 @@ msgid "Edited: {editedDateText}"
msgstr "" msgstr ""
#: src/components/status.jsx:1187 #: src/components/status.jsx:1187
#: src/components/status.jsx:3186 #: src/components/status.jsx:3188
msgid "Embed post" msgid "Embed post"
msgstr "" msgstr ""
@ -2223,77 +2223,77 @@ msgstr ""
msgid "More from <0/>" msgid "More from <0/>"
msgstr "More from <0/>" msgstr "More from <0/>"
#: src/components/status.jsx:2947 #: src/components/status.jsx:2949
msgid "Edit History" msgid "Edit History"
msgstr "" msgstr ""
#: src/components/status.jsx:2951 #: src/components/status.jsx:2953
msgid "Failed to load history" msgid "Failed to load history"
msgstr "" msgstr ""
#: src/components/status.jsx:2956 #: src/components/status.jsx:2958
msgid "Loading…" msgid "Loading…"
msgstr "" msgstr ""
#: src/components/status.jsx:3191 #: src/components/status.jsx:3193
msgid "HTML Code" msgid "HTML Code"
msgstr "" msgstr ""
#: src/components/status.jsx:3208 #: src/components/status.jsx:3210
msgid "HTML code copied" msgid "HTML code copied"
msgstr "" msgstr ""
#: src/components/status.jsx:3211 #: src/components/status.jsx:3213
msgid "Unable to copy HTML code" msgid "Unable to copy HTML code"
msgstr "" msgstr ""
#: src/components/status.jsx:3223 #: src/components/status.jsx:3225
msgid "Media attachments:" msgid "Media attachments:"
msgstr "" msgstr ""
#: src/components/status.jsx:3245 #: src/components/status.jsx:3247
msgid "Account Emojis:" msgid "Account Emojis:"
msgstr "" msgstr ""
#: src/components/status.jsx:3276 #: src/components/status.jsx:3278
#: src/components/status.jsx:3321 #: src/components/status.jsx:3323
msgid "static URL" msgid "static URL"
msgstr "" msgstr ""
#: src/components/status.jsx:3290 #: src/components/status.jsx:3292
msgid "Emojis:" msgid "Emojis:"
msgstr "" msgstr ""
#: src/components/status.jsx:3335 #: src/components/status.jsx:3337
msgid "Notes:" msgid "Notes:"
msgstr "" msgstr ""
#: src/components/status.jsx:3339 #: src/components/status.jsx:3341
msgid "This is static, unstyled and scriptless. You may need to apply your own styles and edit as needed." msgid "This is static, unstyled and scriptless. You may need to apply your own styles and edit as needed."
msgstr "" msgstr ""
#: src/components/status.jsx:3345 #: src/components/status.jsx:3347
msgid "Polls are not interactive, becomes a list with vote counts." msgid "Polls are not interactive, becomes a list with vote counts."
msgstr "" msgstr ""
#: src/components/status.jsx:3350 #: src/components/status.jsx:3352
msgid "Media attachments can be images, videos, audios or any file types." msgid "Media attachments can be images, videos, audios or any file types."
msgstr "" msgstr ""
#: src/components/status.jsx:3356 #: src/components/status.jsx:3358
msgid "Post could be edited or deleted later." msgid "Post could be edited or deleted later."
msgstr "" msgstr ""
#: src/components/status.jsx:3362 #: src/components/status.jsx:3364
msgid "Preview" msgid "Preview"
msgstr "" msgstr ""
#: src/components/status.jsx:3371 #: src/components/status.jsx:3373
msgid "Note: This preview is lightly styled." msgid "Note: This preview is lightly styled."
msgstr "" msgstr ""
#. [Name] [Visibility icon] boosted #. [Name] [Visibility icon] boosted
#: src/components/status.jsx:3613 #: src/components/status.jsx:3615
msgid "<0/> <1/> boosted" msgid "<0/> <1/> boosted"
msgstr "" msgstr ""

View file

@ -8,7 +8,7 @@ function emojifyText(text, emojis = []) {
const { shortcode, staticUrl, url } = emoji; const { shortcode, staticUrl, url } = emoji;
text = text.replace( text = text.replace(
new RegExp(`:${shortcode}:`, 'g'), new RegExp(`:${shortcode}:`, 'g'),
`<picture><source srcset="${staticUrl}" media="(prefers-reduced-motion: reduce)"></source><img class="shortcode-emoji emoji" src="${url}" alt=":${shortcode}:" width="16" height="16" loading="lazy" decoding="async" /></picture>`, `<picture><source srcset="${staticUrl}" media="(prefers-reduced-motion: reduce)"></source><img class="shortcode-emoji emoji" src="${url}" alt=":${shortcode}:" width="16" height="16" loading="lazy" decoding="async" fetchPriority="low" /></picture>`,
); );
}); });
// console.log(text, emojis); // console.log(text, emojis);