<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
  <id>https://web.dev/</id>
  <title>Luna Lu on web.dev</title>
  <updated>2026-04-15T23:21:06Z</updated>
  <author>
    <name>Luna Lu</name>
  </author>
  <link href="https://web.dev/authors/lunalu/feed.xml" rel="self"/>
  <link href="https://web.dev/"/>
  <icon>https://web-dev.imgix.net/image/admin/NTv1ih4WoIEUdRA0psCk.jpg?auto=format</icon>
  <logo>https://web.dev/images/shared/rss-banner.png</logo>
  <subtitle>Build and enforce guardrails for the web.</subtitle>
  
  
  <entry>
    <title>Image policies for fast load times and more</title>
    <link href="https://web.dev/image-policies/"/>
    <updated>2019-05-31T00:00:00Z</updated>
    <id>https://web.dev/image-policies/</id>
    <content type="html" mode="escaped">&lt;p&gt;Images often take up a significant amount of visual space and make up the
majority of the downloaded bytes on a website. Optimizing images can improve
loading performance and reduce network traffic.&lt;/p&gt;
&lt;p&gt;Surprisingly, more than half of the sites on the web are serving poorly
compressed or unnecessarily large images. This leaves a lot of room for
performance improvements simply by optimizing the images.&lt;/p&gt;
&lt;p&gt;You may ask, how do I know if my images are optimized and how should I optimize
them? We are experimenting with a new set of feature policies for image
optimization: &lt;code&gt;oversized-images&lt;/code&gt;, &lt;code&gt;unoptimized-lossy-images&lt;/code&gt;,
&lt;code&gt;unoptimized-lossless-images&lt;/code&gt;, and&lt;code&gt;unoptimized-lossless-images-strict&lt;/code&gt;.
All are now available for &lt;a href=&quot;https://github.com/GoogleChrome/OriginTrials/blob/gh-pages/developer-guide.md&quot; rel=&quot;noopener&quot;&gt;origin
trials&lt;/a&gt;.&lt;/p&gt;
&lt;h2 id=&quot;optimized-image-policies&quot;&gt;Optimized image policies &lt;a class=&quot;headline-link&quot; href=&quot;https://web.dev/image-policies/#optimized-image-policies&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Permissions policy is introducing a new set restrictions on images that can be
applied with development-time enforcement. Images violating any of the
restrictions will be rendered as placeholder images, which are easy to identify
and fix. These policies can be specified in report-only mode where images will
render normally without enforcement while violations are being observed via
reports. (See &lt;a href=&quot;https://web.dev/image-policies/#report-only-mode-in-the-wild&quot;&gt;Report-only mode in the wild&lt;/a&gt;,
below for details.)&lt;/p&gt;
&lt;h3 id=&quot;oversized-images&quot;&gt;oversized-images &lt;a class=&quot;headline-link&quot; href=&quot;https://web.dev/image-policies/#oversized-images&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;The &lt;code&gt;oversized-images&lt;/code&gt; permissions policy restricts the intrinsic dimensions
of an image in relation to its container size.&lt;/p&gt;
&lt;p&gt;When a document uses the &lt;code&gt;oversized-images&lt;/code&gt; policy, any &lt;code&gt;&amp;lt;img&amp;gt;&lt;/code&gt; element
whose intrinsic resolution is more than X times larger than the container size
in either dimension will be replaced with a placeholder image.&lt;/p&gt;
&lt;h4 id=&quot;why&quot;&gt;Why? &lt;a class=&quot;headline-link&quot; href=&quot;https://web.dev/image-policies/#why&quot;&gt;#&lt;/a&gt;&lt;/h4&gt;
&lt;p&gt;Serving images larger than what the viewing device can render—for example,
serving desktop images to mobile contexts, or serving high-pixel-density images
to a low-pixel-density device—is wasting network traffic and device
memory. Read &lt;a href=&quot;https://web.dev/serve-images-with-correct-dimensions/&quot;&gt;Serve images with correct dimensions&lt;/a&gt;
and &lt;a href=&quot;https://web.dev/serve-responsive-images/&quot;&gt;Serve responsive images&lt;/a&gt;
for information on optimizing your images.&lt;/p&gt;
&lt;h4 id=&quot;examples&quot;&gt;Examples &lt;a class=&quot;headline-link&quot; href=&quot;https://web.dev/image-policies/#examples&quot;&gt;#&lt;/a&gt;&lt;/h4&gt;
&lt;p&gt;A few examples illustrate this. The following shows the default behavior when cutting an image&#39;s display size in half.&lt;/p&gt;
&lt;figure&gt;
  &lt;img alt=&quot;The default resizing behavior.&quot; decoding=&quot;async&quot; height=&quot;401&quot; loading=&quot;lazy&quot; sizes=&quot;(min-width: 326px) 326px, calc(100vw - 48px)&quot; src=&quot;https://web-dev.imgix.net/image/admin/QR01OUN3VXTbOhhSOZBz.png?auto=format&quot; srcset=&quot;https://web-dev.imgix.net/image/admin/QR01OUN3VXTbOhhSOZBz.png?auto=format&amp;w=200 200w, https://web-dev.imgix.net/image/admin/QR01OUN3VXTbOhhSOZBz.png?auto=format&amp;w=228 228w, https://web-dev.imgix.net/image/admin/QR01OUN3VXTbOhhSOZBz.png?auto=format&amp;w=260 260w, https://web-dev.imgix.net/image/admin/QR01OUN3VXTbOhhSOZBz.png?auto=format&amp;w=296 296w, https://web-dev.imgix.net/image/admin/QR01OUN3VXTbOhhSOZBz.png?auto=format&amp;w=338 338w, https://web-dev.imgix.net/image/admin/QR01OUN3VXTbOhhSOZBz.png?auto=format&amp;w=385 385w, https://web-dev.imgix.net/image/admin/QR01OUN3VXTbOhhSOZBz.png?auto=format&amp;w=439 439w, https://web-dev.imgix.net/image/admin/QR01OUN3VXTbOhhSOZBz.png?auto=format&amp;w=500 500w, https://web-dev.imgix.net/image/admin/QR01OUN3VXTbOhhSOZBz.png?auto=format&amp;w=571 571w, https://web-dev.imgix.net/image/admin/QR01OUN3VXTbOhhSOZBz.png?auto=format&amp;w=650 650w, https://web-dev.imgix.net/image/admin/QR01OUN3VXTbOhhSOZBz.png?auto=format&amp;w=652 652w&quot; width=&quot;326&quot; /&gt;
  &lt;figcaption&gt;The default resizing behavior.&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;p&gt;If I apply the following permissions policy, I get a placeholder image instead.&lt;/p&gt;
&lt;p&gt;&lt;code&gt;Permissions-Policy: oversized-images *(2);&lt;/code&gt;&lt;/p&gt;
&lt;figure&gt;
  &lt;img alt=&quot;When the image is too large for the container.&quot; decoding=&quot;async&quot; height=&quot;401&quot; loading=&quot;lazy&quot; sizes=&quot;(min-width: 326px) 326px, calc(100vw - 48px)&quot; src=&quot;https://web-dev.imgix.net/image/admin/NErIMVS4qsSVHek2UtDZ.png?auto=format&quot; srcset=&quot;https://web-dev.imgix.net/image/admin/NErIMVS4qsSVHek2UtDZ.png?auto=format&amp;w=200 200w, https://web-dev.imgix.net/image/admin/NErIMVS4qsSVHek2UtDZ.png?auto=format&amp;w=228 228w, https://web-dev.imgix.net/image/admin/NErIMVS4qsSVHek2UtDZ.png?auto=format&amp;w=260 260w, https://web-dev.imgix.net/image/admin/NErIMVS4qsSVHek2UtDZ.png?auto=format&amp;w=296 296w, https://web-dev.imgix.net/image/admin/NErIMVS4qsSVHek2UtDZ.png?auto=format&amp;w=338 338w, https://web-dev.imgix.net/image/admin/NErIMVS4qsSVHek2UtDZ.png?auto=format&amp;w=385 385w, https://web-dev.imgix.net/image/admin/NErIMVS4qsSVHek2UtDZ.png?auto=format&amp;w=439 439w, https://web-dev.imgix.net/image/admin/NErIMVS4qsSVHek2UtDZ.png?auto=format&amp;w=500 500w, https://web-dev.imgix.net/image/admin/NErIMVS4qsSVHek2UtDZ.png?auto=format&amp;w=571 571w, https://web-dev.imgix.net/image/admin/NErIMVS4qsSVHek2UtDZ.png?auto=format&amp;w=650 650w, https://web-dev.imgix.net/image/admin/NErIMVS4qsSVHek2UtDZ.png?auto=format&amp;w=652 652w&quot; width=&quot;326&quot; /&gt;
  &lt;figcaption&gt;When the image is too large for the container.&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;p&gt;I get similar results if I lower only the width or the height.&lt;/p&gt;
&lt;figure&gt;
  &lt;img alt=&quot;Resized width&quot; decoding=&quot;async&quot; height=&quot;401&quot; loading=&quot;lazy&quot; sizes=&quot;(min-width: 326px) 326px, calc(100vw - 48px)&quot; src=&quot;https://web-dev.imgix.net/image/admin/S11HV1w6uqkXq6GDRKVx.png?auto=format&quot; srcset=&quot;https://web-dev.imgix.net/image/admin/S11HV1w6uqkXq6GDRKVx.png?auto=format&amp;w=200 200w, https://web-dev.imgix.net/image/admin/S11HV1w6uqkXq6GDRKVx.png?auto=format&amp;w=228 228w, https://web-dev.imgix.net/image/admin/S11HV1w6uqkXq6GDRKVx.png?auto=format&amp;w=260 260w, https://web-dev.imgix.net/image/admin/S11HV1w6uqkXq6GDRKVx.png?auto=format&amp;w=296 296w, https://web-dev.imgix.net/image/admin/S11HV1w6uqkXq6GDRKVx.png?auto=format&amp;w=338 338w, https://web-dev.imgix.net/image/admin/S11HV1w6uqkXq6GDRKVx.png?auto=format&amp;w=385 385w, https://web-dev.imgix.net/image/admin/S11HV1w6uqkXq6GDRKVx.png?auto=format&amp;w=439 439w, https://web-dev.imgix.net/image/admin/S11HV1w6uqkXq6GDRKVx.png?auto=format&amp;w=500 500w, https://web-dev.imgix.net/image/admin/S11HV1w6uqkXq6GDRKVx.png?auto=format&amp;w=571 571w, https://web-dev.imgix.net/image/admin/S11HV1w6uqkXq6GDRKVx.png?auto=format&amp;w=650 650w, https://web-dev.imgix.net/image/admin/S11HV1w6uqkXq6GDRKVx.png?auto=format&amp;w=652 652w&quot; width=&quot;326&quot; /&gt;
  &lt;img alt=&quot;Resized height&quot; decoding=&quot;async&quot; height=&quot;401&quot; loading=&quot;lazy&quot; sizes=&quot;(min-width: 326px) 326px, calc(100vw - 48px)&quot; src=&quot;https://web-dev.imgix.net/image/admin/dMPfyFsJ5qexNSj0Q8Ia.png?auto=format&quot; srcset=&quot;https://web-dev.imgix.net/image/admin/dMPfyFsJ5qexNSj0Q8Ia.png?auto=format&amp;w=200 200w, https://web-dev.imgix.net/image/admin/dMPfyFsJ5qexNSj0Q8Ia.png?auto=format&amp;w=228 228w, https://web-dev.imgix.net/image/admin/dMPfyFsJ5qexNSj0Q8Ia.png?auto=format&amp;w=260 260w, https://web-dev.imgix.net/image/admin/dMPfyFsJ5qexNSj0Q8Ia.png?auto=format&amp;w=296 296w, https://web-dev.imgix.net/image/admin/dMPfyFsJ5qexNSj0Q8Ia.png?auto=format&amp;w=338 338w, https://web-dev.imgix.net/image/admin/dMPfyFsJ5qexNSj0Q8Ia.png?auto=format&amp;w=385 385w, https://web-dev.imgix.net/image/admin/dMPfyFsJ5qexNSj0Q8Ia.png?auto=format&amp;w=439 439w, https://web-dev.imgix.net/image/admin/dMPfyFsJ5qexNSj0Q8Ia.png?auto=format&amp;w=500 500w, https://web-dev.imgix.net/image/admin/dMPfyFsJ5qexNSj0Q8Ia.png?auto=format&amp;w=571 571w, https://web-dev.imgix.net/image/admin/dMPfyFsJ5qexNSj0Q8Ia.png?auto=format&amp;w=650 650w, https://web-dev.imgix.net/image/admin/dMPfyFsJ5qexNSj0Q8Ia.png?auto=format&amp;w=652 652w&quot; width=&quot;326&quot; /&gt;
  &lt;figcaption&gt;
    Resize width and height.
  &lt;/figcaption&gt;
&lt;/figure&gt;
&lt;h4 id=&quot;how-to-use&quot;&gt;How to use &lt;a class=&quot;headline-link&quot; href=&quot;https://web.dev/image-policies/#how-to-use&quot;&gt;#&lt;/a&gt;&lt;/h4&gt;
&lt;p&gt;To summarize, &lt;code&gt;oversized-images&lt;/code&gt; policy can be specified through either:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;Permissions-Policy&lt;/code&gt; HTTP header&lt;/li&gt;
&lt;li&gt;&lt;code&gt;&amp;lt;iframe&amp;gt;&lt;/code&gt; &lt;code&gt;allow&lt;/code&gt; attribute&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;To declare the &lt;code&gt;oversized-images&lt;/code&gt; policy, you need to provide:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;The feature name, &lt;code&gt;oversized-images&lt;/code&gt; (Required)&lt;/li&gt;
&lt;li&gt;A list of origins (Optional)&lt;/li&gt;
&lt;li&gt;The threshold values (i.e., the downscaling ratio X) for the origins, specified in
parenthesis (Optional)&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;We recommend a downscaling ratio of 2.0 or lower. Consider using
&lt;a href=&quot;https://web.dev/serve-responsive-images/&quot;&gt;responsive images&lt;/a&gt; with different resolutions to
best serve images on various screen sizes, resolutions, and so on.&lt;/p&gt;
&lt;h4 id=&quot;more-examples&quot;&gt;More examples &lt;a class=&quot;headline-link&quot; href=&quot;https://web.dev/image-policies/#more-examples&quot;&gt;#&lt;/a&gt;&lt;/h4&gt;
&lt;p&gt;&lt;code&gt;Permissions-Policy: oversized-images *(2.0)&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;The policy is enforced on all origins with a threshold value of 2.0. Any
&lt;code&gt;&amp;lt;img&amp;gt;&lt;/code&gt; element with an image whose downscaling ratio that is greater than
2.0 is disallowed and will be replaced with a placeholder image.&lt;/p&gt;
&lt;p&gt;&lt;code&gt;Permissions-Policy: oversized-images *(inf) &#39;self&#39;(1.5)&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;The policy is enforced on the site&#39;s origin with a threshold value of 1.5.
&lt;code&gt;&amp;lt;img&amp;gt;&lt;/code&gt; elements in top-level browsing contexts and same origin nested
browsing contexts will only render normally if the downscaling ratio is less
than or equal to 1.5. &lt;code&gt;&amp;lt;img&amp;gt;&lt;/code&gt; elements everywhere else will render normally.&lt;/p&gt;
&lt;h3 id=&quot;unoptimized-{lossy,lossless}-images&quot;&gt;unoptimized-{lossy,lossless}-images &lt;a class=&quot;headline-link&quot; href=&quot;https://web.dev/image-policies/#unoptimized-{lossy,lossless}-images&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;The &lt;code&gt;unoptimized-lossy-images&lt;/code&gt;, &lt;code&gt;unoptimized-lossless-images&lt;/code&gt;,
&lt;code&gt;unoptimized-lossless-images-strict&lt;/code&gt; feature policies restrict the file
size of an image in relation to its intrinsic resolution:&lt;/p&gt;
&lt;dl&gt;
  &lt;dt&gt;&lt;code&gt;unoptimized-lossy-images&lt;/code&gt;&lt;/dt&gt;
  &lt;dd&gt;Lossy formats should not exceed a byte-per-pixel ratio of X, with a fixed &lt;strong&gt;1KB&lt;/strong&gt; overhead allowance. For a W x H image, the file size threshold is calculated as W x H x X + 1024.&lt;/dd&gt;
  &lt;dt&gt;&lt;code&gt;unoptimized-lossless-images&lt;/code&gt;&lt;/dt&gt;
  &lt;dd&gt;Lossless formats should not exceed a byte-per-pixel ratio of X, with a fixed &lt;strong&gt;10KB&lt;/strong&gt; overhead allowance. For a W x H image, the file size threshold is calculated as W x H x X + 10240.&lt;/dd&gt;
  &lt;dt&gt;&lt;code&gt;unoptimized-lossless-images-strict&lt;/code&gt;&lt;/dt&gt;
  &lt;dd&gt;Lossless formats should not exceed a byte-per-pixel ratio of X, with a fixed &lt;strong&gt;1KB&lt;/strong&gt; overhead allowance. For a W x H image, the file size threshold is calculated as W x H x X + 1024.&lt;/dd&gt;
&lt;/dl&gt;
&lt;p&gt;When a document uses any of these policies, any &lt;code&gt;&amp;lt;img&amp;gt;&lt;/code&gt; element violating
the constraint will be replaced with a placeholder image.&lt;/p&gt;
&lt;h4 id=&quot;why-2&quot;&gt;Why? &lt;a class=&quot;headline-link&quot; href=&quot;https://web.dev/image-policies/#why-2&quot;&gt;#&lt;/a&gt;&lt;/h4&gt;
&lt;p&gt;The larger the download size is, the longer it takes for an image to load. The
file size should be kept as small as possible when optimizing an image:
stripping metadata, picking a good image format, using image compression, and so on.
Read &lt;a href=&quot;https://web.dev/use-imagemin-to-compress-images/&quot;&gt;Use Imagemin to compress images&lt;/a&gt; and
&lt;a href=&quot;https://web.dev/serve-images-webp/&quot;&gt;Use WebP images&lt;/a&gt; for information on
optimizing your images.&lt;/p&gt;
&lt;h4 id=&quot;example&quot;&gt;Example &lt;a class=&quot;headline-link&quot; href=&quot;https://web.dev/image-policies/#example&quot;&gt;#&lt;/a&gt;&lt;/h4&gt;
&lt;p&gt;The following shows the default browser behavior. Without the permissions policy an unoptimized lossy image can be displayed just the same as an optimized image.&lt;/p&gt;
&lt;figure&gt;
  &lt;img alt=&quot;Comparing an optimized image with an unoptimized image.&quot; decoding=&quot;async&quot; height=&quot;401&quot; loading=&quot;lazy&quot; sizes=&quot;(min-width: 326px) 326px, calc(100vw - 48px)&quot; src=&quot;https://web-dev.imgix.net/image/admin/kxabc5874fW5IvPnqR9E.png?auto=format&quot; srcset=&quot;https://web-dev.imgix.net/image/admin/kxabc5874fW5IvPnqR9E.png?auto=format&amp;w=200 200w, https://web-dev.imgix.net/image/admin/kxabc5874fW5IvPnqR9E.png?auto=format&amp;w=228 228w, https://web-dev.imgix.net/image/admin/kxabc5874fW5IvPnqR9E.png?auto=format&amp;w=260 260w, https://web-dev.imgix.net/image/admin/kxabc5874fW5IvPnqR9E.png?auto=format&amp;w=296 296w, https://web-dev.imgix.net/image/admin/kxabc5874fW5IvPnqR9E.png?auto=format&amp;w=338 338w, https://web-dev.imgix.net/image/admin/kxabc5874fW5IvPnqR9E.png?auto=format&amp;w=385 385w, https://web-dev.imgix.net/image/admin/kxabc5874fW5IvPnqR9E.png?auto=format&amp;w=439 439w, https://web-dev.imgix.net/image/admin/kxabc5874fW5IvPnqR9E.png?auto=format&amp;w=500 500w, https://web-dev.imgix.net/image/admin/kxabc5874fW5IvPnqR9E.png?auto=format&amp;w=571 571w, https://web-dev.imgix.net/image/admin/kxabc5874fW5IvPnqR9E.png?auto=format&amp;w=650 650w, https://web-dev.imgix.net/image/admin/kxabc5874fW5IvPnqR9E.png?auto=format&amp;w=652 652w&quot; width=&quot;326&quot; /&gt;
  &lt;figcaption&gt;Comparing an optimized image with an unoptimized image.&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;p&gt;If I apply the following permissions policy, I get a placeholder image instead.&lt;/p&gt;
&lt;p&gt;&lt;code&gt;Permissions-Policy: unoptimized-lossy-images *(0.5);&lt;/code&gt;&lt;/p&gt;
&lt;figure&gt;
  &lt;img alt=&quot;When the image is not optimized.&quot; decoding=&quot;async&quot; height=&quot;401&quot; loading=&quot;lazy&quot; sizes=&quot;(min-width: 326px) 326px, calc(100vw - 48px)&quot; src=&quot;https://web-dev.imgix.net/image/admin/Y0cCIEuFI1M3DaKfxBkI.png?auto=format&quot; srcset=&quot;https://web-dev.imgix.net/image/admin/Y0cCIEuFI1M3DaKfxBkI.png?auto=format&amp;w=200 200w, https://web-dev.imgix.net/image/admin/Y0cCIEuFI1M3DaKfxBkI.png?auto=format&amp;w=228 228w, https://web-dev.imgix.net/image/admin/Y0cCIEuFI1M3DaKfxBkI.png?auto=format&amp;w=260 260w, https://web-dev.imgix.net/image/admin/Y0cCIEuFI1M3DaKfxBkI.png?auto=format&amp;w=296 296w, https://web-dev.imgix.net/image/admin/Y0cCIEuFI1M3DaKfxBkI.png?auto=format&amp;w=338 338w, https://web-dev.imgix.net/image/admin/Y0cCIEuFI1M3DaKfxBkI.png?auto=format&amp;w=385 385w, https://web-dev.imgix.net/image/admin/Y0cCIEuFI1M3DaKfxBkI.png?auto=format&amp;w=439 439w, https://web-dev.imgix.net/image/admin/Y0cCIEuFI1M3DaKfxBkI.png?auto=format&amp;w=500 500w, https://web-dev.imgix.net/image/admin/Y0cCIEuFI1M3DaKfxBkI.png?auto=format&amp;w=571 571w, https://web-dev.imgix.net/image/admin/Y0cCIEuFI1M3DaKfxBkI.png?auto=format&amp;w=650 650w, https://web-dev.imgix.net/image/admin/Y0cCIEuFI1M3DaKfxBkI.png?auto=format&amp;w=652 652w&quot; width=&quot;326&quot; /&gt;
  &lt;figcaption&gt;When the image is not optimized.&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;h4 id=&quot;how-to-use-2&quot;&gt;How to use &lt;a class=&quot;headline-link&quot; href=&quot;https://web.dev/image-policies/#how-to-use-2&quot;&gt;#&lt;/a&gt;&lt;/h4&gt;
&lt;p&gt;If you are new to permissions policy, please check out &lt;a href=&quot;https://developer.chrome.com/docs/privacy-sandbox/permissions-policy/&quot; rel=&quot;noopener&quot;&gt;Introduction to Permissions
Policy&lt;/a&gt; for
more details.&lt;/p&gt;
&lt;p&gt;To summarize, &lt;code&gt;unoptimized-{lossy,lossless}-images&lt;/code&gt; policies can be either
specified through:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;Permissions-Policy&lt;/code&gt; HTTP header&lt;/li&gt;
&lt;li&gt;&lt;code&gt;&amp;lt;iframe&amp;gt;&lt;/code&gt; &lt;code&gt;allow&lt;/code&gt; attribute&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;To declare an &lt;code&gt;unoptimized-{lossy,lossless}-images&lt;/code&gt; policy, you will need to
provide:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;The feature name, for example, &lt;code&gt;unoptimized-lossy-images&lt;/code&gt; (Required)&lt;/li&gt;
&lt;li&gt;A list of origins (Optional)&lt;/li&gt;
&lt;li&gt;The threshold values (i.e., byte-per-pixel ratio X) for the origins, specified
in parenthesis (Optional)&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;We recommend a byte-per-pixel ratio of 0.5 or lower for
&lt;code&gt;unoptimized-lossy-images&lt;/code&gt; and a byte-per-pixel ratio of 1 or lower for
&lt;code&gt;unoptimized-lossless-images&lt;/code&gt; and &lt;code&gt;unoptimized-lossless-images-strict&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;WebP formats have better compression ratios than other formats. Serve all your
images in WebP lossy format if you can. If that is not sufficient, try WebP
lossless format. Use JPEG on browsers that don&#39;t support WebP formats. Use PNG
if none of thes formats work.&lt;/p&gt;
&lt;p&gt;If you are using WebP formats, try with stricter thresholds:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;0.2 for WEBPV8&lt;/li&gt;
&lt;li&gt;0.5 for WEBPL&lt;/li&gt;
&lt;/ul&gt;
&lt;h4 id=&quot;more-examples-2&quot;&gt;More examples &lt;a class=&quot;headline-link&quot; href=&quot;https://web.dev/image-policies/#more-examples-2&quot;&gt;#&lt;/a&gt;&lt;/h4&gt;
&lt;div&gt;&lt;pre class=&quot;language-text&quot;&gt;&lt;code class=&quot;language-text&quot;&gt;Feature-Policy:  unoptimized-lossy-images *(0.5);&lt;br /&gt;                 unoptimized-lossless-images *(1.0);&lt;br /&gt;                 unoptimized-lossless-images-strict *(1.0);&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;&lt;p&gt;This policy is enforced on all origins with a threshold value of 0.5 (for lossy
formats) and 1 (for lossless formats). Any &lt;code&gt;&amp;lt;img&amp;gt;&lt;/code&gt; element whose image has a
byte-per-pixel ratio exceeding the constraint is disallowed and will be replaced
with a placeholder image.&lt;/p&gt;
&lt;div&gt;&lt;pre class=&quot;language-text&quot;&gt;&lt;code class=&quot;language-text&quot;&gt;Feature-Policy: unoptimized-lossy-images *(inf) &#39;self&#39;(0.3);&lt;br /&gt;                unoptimized-lossless-images *(inf) &#39;self&#39;(0.8);&lt;br /&gt;                unoptimized-lossless-images-strict *(inf) &#39;self&#39;(0.8);&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;&lt;p&gt;This policy is enforced on the site&#39;s origin with a threshold value of 0.3 (for
lossy formats) and 0.8 (for lossless formats). The &lt;code&gt;&amp;lt;img&amp;gt;&lt;/code&gt; elements in top-level
browsing contexts and same origin nested browsing contexts will only render
normally if the byte-per-pixel ratio meets these constraints. The &lt;code&gt;&amp;lt;img&amp;gt;&lt;/code&gt; elements
everywhere else will render normally.&lt;/p&gt;
&lt;h3 id=&quot;report-only-mode-in-the-wild&quot;&gt;Report-only mode in the wild &lt;a class=&quot;headline-link&quot; href=&quot;https://web.dev/image-policies/#report-only-mode-in-the-wild&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Publishing a site with placeholder images may not be what you want. You can use
the policies in enforcement mode (with unoptimized images rendered as
placeholder images) during development and staging, and use report-only mode in
production. (Check out &lt;a href=&quot;https://github.com/w3c/webappsec-permissions-policy/blob/master/reporting.md&quot; rel=&quot;noopener&quot;&gt;Permissions Policy
Reporting&lt;/a&gt;
for more details.) Similar to &lt;code&gt;Permissions-Policy&lt;/code&gt; HTTP header, the
&lt;code&gt;Permissions-Policy-Report-Only&lt;/code&gt; header lets you observe violation reports in the
wild without any enforcement.&lt;/p&gt;
&lt;h3 id=&quot;limitations&quot;&gt;Limitations &lt;a class=&quot;headline-link&quot; href=&quot;https://web.dev/image-policies/#limitations&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Image policies only work on HTML image elements (&lt;code&gt;&amp;lt;img&amp;gt;&lt;/code&gt;, &lt;code&gt;&amp;lt;source&amp;gt;&lt;/code&gt;,
etc.) and are not yet supported on background images or generated content. If you
would like to have policies supported on broader contents, please let us know.&lt;/p&gt;
&lt;h2 id=&quot;optimizing-your-images&quot;&gt;Optimizing your images &lt;a class=&quot;headline-link&quot; href=&quot;https://web.dev/image-policies/#optimizing-your-images&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;I&#39;ve talked quite a bit about optimizing your images, but haven&#39;t said how to do it. That topic is out of scope for this article, but you can learn more from the links below and from the codelabs listed at the end of the article.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;https://web.dev/fast#optimize-your-images&quot;&gt;Optimizing images&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://web.dev/serve-images-with-correct-dimensions/&quot;&gt;Serve images with correct dimensions&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;please-give-us-feedback&quot;&gt;Please give us feedback &lt;a class=&quot;headline-link&quot; href=&quot;https://web.dev/image-policies/#please-give-us-feedback&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Hopefully this article has given you a good understanding of the image policies
and gotten you excited. We&#39;d really love for you to try out the policies and
give us feedback.&lt;/p&gt;
&lt;p&gt;You can give us feedback for each of the features mentioned in this article to
our mailing list: &lt;a href=&quot;mailto:feature-control@chromium.org&quot; rel=&quot;noopener&quot;&gt;feature-control@&lt;/a&gt;&lt;a href=&quot;mailto:feature-control@chromium.org&quot; rel=&quot;noopener&quot;&gt;chromium.org&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;We would love to know what threshold values you used and found useful. We would
love to know whether &lt;code&gt;unoptimized-lossless-images&lt;/code&gt; or
&lt;code&gt;unoptimized-lossless-images-strict&lt;/code&gt; is more intuitive and easy to use, or if we
should use a difference overhead allowance instead. We will be sending out a
survey near the end of the trial. Stay tuned!&lt;/p&gt;
</content>
    <author>
      <name>Luna Lu</name>
    </author>
  </entry>
</feed>
