{"id":401851,"date":"2024-06-05T08:00:00","date_gmt":"2024-06-05T08:00:00","guid":{"rendered":"https:\/\/www.weixiaoduo.com\/plugins\/image-prioritizer\/"},"modified":"2025-04-09T23:06:00","modified_gmt":"2025-04-09T23:06:00","slug":"image-prioritizer","status":"publish","type":"post","link":"https:\/\/www.weixiaoduo.com\/plugins\/image-prioritizer\/","title":{"rendered":"Image Prioritizer"},"content":{"rendered":"<p>This plugin optimizes the loading of images (and videos) with prioritization to improve <a href=\"https:\/\/web.dev\/articles\/lcp\" rel=\"nofollow ugc\">Largest Contentful Paint<\/a> (LCP), lazy loading, and more accurate image size selection.<\/p>\n<p>The current optimizations include:<\/p>\n<ol>\n<li>Add breakpoint-specific <code>fetchpriority=high<\/code> preload links (both as <code>LINK[rel=preload]<\/code> elements and <code>Link<\/code> response headers) for image URLs of LCP elements:\n<ol>\n<li>An <code>IMG<\/code> element, including the <code>srcset<\/code>\/<code>sizes<\/code> attributes supplied as <code>imagesrcset<\/code>\/<code>imagesizes<\/code> on the <code>LINK<\/code>.<\/li>\n<li>The first <code>SOURCE<\/code> element with a <code>type<\/code> attribute in a <code>PICTURE<\/code> element. (Art-directed <code>PICTURE<\/code> elements using media queries are not supported.)<\/li>\n<li>An element with a CSS <code>background-image<\/code> inline <code>style<\/code> attribute.<\/li>\n<li>An element with a CSS <code>background-image<\/code> applied with a stylesheet (when the image is from an allowed origin).<\/li>\n<li>A <code>VIDEO<\/code> element\u2019s <code>poster<\/code> image.<\/li>\n<\/ol>\n<\/li>\n<li>Ensure <code>fetchpriority=high<\/code> is only added to an <code>IMG<\/code> when it is the LCP element across all responsive breakpoints.<\/li>\n<li>Add <code>fetchpriority=low<\/code> to <code>IMG<\/code> tags which appear in the initial viewport but are not visible, such as when they are subsequent carousel slides.<\/li>\n<li>Lazy loading:\n<ol>\n<li>Apply lazy loading to <code>IMG<\/code> tags based on whether they appear in any breakpoint\u2019s initial viewport.<\/li>\n<li>Implement lazy loading of CSS background images added via inline <code>style<\/code> attributes.<\/li>\n<li>Lazy-load <code>VIDEO<\/code> tags by setting the appropriate attributes based on whether they appear in the initial viewport. If a <code>VIDEO<\/code> is the LCP element, it gets <code>preload=auto<\/code>; if it is in an initial viewport, the <code>preload=metadata<\/code> default is left; if it is not in an initial viewport, it gets <code>preload=none<\/code>. Lazy-loaded videos also get initial <code>preload<\/code>, <code>autoplay<\/code>, and <code>poster<\/code> attributes restored when the <code>VIDEO<\/code> is going to enter the viewport.<\/li>\n<\/ol>\n<\/li>\n<li>Responsive image sizes:\n<ol>\n<li>Compute the <code>sizes<\/code> attribute using the widths of an image collected from URL Metrics for each breakpoint (when not lazy-loaded since then handled by <code>sizes=auto<\/code>).<\/li>\n<li>Ensure <a href=\"https:\/\/make.wordpress.org\/core\/2024\/10\/18\/auto-sizes-for-lazy-loaded-images-in-wordpress-6-7\/\" rel=\"nofollow ugc\"><code>sizes=auto<\/code><\/a> is set on <code>IMG<\/code> tags after setting correct lazy-loading (above).<\/li>\n<\/ol>\n<\/li>\n<li>Reduce the size of the <code>poster<\/code> image of a <code>VIDEO<\/code> from full size to the size appropriate for the maximum width of the video (on desktop).<\/li>\n<\/ol>\n<p><strong>This plugin requires the <a href=\"https:\/\/wordpress.org\/plugins\/optimization-detective\/\" rel=\"ugc\">Optimization Detective<\/a> plugin as a dependency.<\/strong> Please refer to that plugin for additional background on how this plugin works as well as additional developer options.<\/p>\n<p>\ud83d\udc49 <strong>Note:<\/strong> This plugin optimizes pages for actual visitors, and it depends on visitors to optimize pages. As such, you won\u2019t see optimizations applied immediately after activating the plugin. Please wait for URL Metrics to be gathered for both mobile and desktop visits. And since administrator users are not normal visitors typically, optimizations are not applied for admins by default.<\/p>\n<p>Your site must have the <strong>REST API accessible<\/strong> to unauthenticated frontend visitors since this is how metrics are collected about how a page should be optimized. There are currently <strong>no settings<\/strong> and no user interface for this plugin since it is designed to work without any configuration.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Prioritizes the loading of images and videos based on how they appear to actual visitors: adds fetchpriority, preloads, lazy-loads, and sets sizes.<\/p>\n","protected":false},"author":65,"featured_media":401852,"comment_status":"open","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"slim_seo":{"title":"Image Prioritizer - \u8587\u6653\u6735\u63d2\u4ef6\u76ee\u5f55","description":"Prioritizes the loading of images and videos based on how they appear to actual visitors: adds fetchpriority, preloads, lazy-loads, and sets sizes."},"footnotes":""},"categories":[1],"tags":[223,1572,28710,517,64],"class_list":["post-401851","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-uncategorized","tag-image","tag-lazy-load","tag-lcp","tag-optimization","tag-performance"],"_links":{"self":[{"href":"https:\/\/www.weixiaoduo.com\/plugins\/wp-json\/wp\/v2\/posts\/401851","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.weixiaoduo.com\/plugins\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.weixiaoduo.com\/plugins\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.weixiaoduo.com\/plugins\/wp-json\/wp\/v2\/users\/65"}],"replies":[{"embeddable":true,"href":"https:\/\/www.weixiaoduo.com\/plugins\/wp-json\/wp\/v2\/comments?post=401851"}],"version-history":[{"count":0,"href":"https:\/\/www.weixiaoduo.com\/plugins\/wp-json\/wp\/v2\/posts\/401851\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.weixiaoduo.com\/plugins\/wp-json\/wp\/v2\/media\/401852"}],"wp:attachment":[{"href":"https:\/\/www.weixiaoduo.com\/plugins\/wp-json\/wp\/v2\/media?parent=401851"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.weixiaoduo.com\/plugins\/wp-json\/wp\/v2\/categories?post=401851"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.weixiaoduo.com\/plugins\/wp-json\/wp\/v2\/tags?post=401851"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}