<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: zhiwei wang</title>
    <description>The latest articles on DEV Community by zhiwei wang (@zhiwei_wang_a8e83fd894cf9).</description>
    <link>https://dev.to/zhiwei_wang_a8e83fd894cf9</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4215438%2Fc5a8f700-57c4-4b3d-bcff-bc69db37442f.png</url>
      <title>DEV Community: zhiwei wang</title>
      <link>https://dev.to/zhiwei_wang_a8e83fd894cf9</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/zhiwei_wang_a8e83fd894cf9"/>
    <language>en</language>
    <item>
      <title>JPEG vs WebP vs AVIF: A Practical Guide to Image Formats in 2026</title>
      <dc:creator>zhiwei wang</dc:creator>
      <pubDate>Fri, 30 Oct 2026 05:03:48 +0000</pubDate>
      <link>https://dev.to/zhiwei_wang_a8e83fd894cf9/jpeg-vs-webp-vs-avif-a-practical-guide-to-image-formats-in-2026-1c46</link>
      <guid>https://dev.to/zhiwei_wang_a8e83fd894cf9/jpeg-vs-webp-vs-avif-a-practical-guide-to-image-formats-in-2026-1c46</guid>
      <description>&lt;p&gt;If you've ever stared at a Lighthouse report and wondered why your "Performance" score refuses to move, the answer is usually sitting right in front of you: the images. On a typical content-heavy page, images are often the heaviest assets on the page, and the single biggest lever you have is choosing the right format and the right compression settings.&lt;/p&gt;

&lt;p&gt;Here's a practical, no-fluff guide to the three formats that matter in 2026 — JPEG, WebP, and AVIF — and how to actually use them.&lt;/p&gt;

&lt;h2&gt;
  
  
  What each format is actually good at
&lt;/h2&gt;

&lt;h3&gt;
  
  
  JPEG — the universal workhorse
&lt;/h3&gt;

&lt;p&gt;JPEG has been around since 1992, and every browser made in the last quarter century supports it. It's a &lt;strong&gt;lossy&lt;/strong&gt; format designed for photographs: it throws away subtle detail the human eye is unlikely to notice in order to shrink the file.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Best for:&lt;/strong&gt; photos, hero images, and anything where you need a guaranteed fallback.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Strengths:&lt;/strong&gt; universal support, simple, predictable.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Weaknesses:&lt;/strong&gt; no transparency, and at small file sizes you start seeing blocky compression artifacts.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  WebP — the modern default
&lt;/h3&gt;

&lt;p&gt;WebP was introduced by Google and supports both &lt;strong&gt;lossy and lossless&lt;/strong&gt; compression, plus transparency (alpha channel) and even animation. At a comparable visual quality, a lossy WebP is usually noticeably smaller than an equivalent JPEG.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Best for:&lt;/strong&gt; the everyday format for most web images.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Strengths:&lt;/strong&gt; good compression, transparency, very wide support.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Weaknesses:&lt;/strong&gt; a tiny fraction of very old browsers still don't support it, so a fallback is prudent.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  AVIF — the next-generation option
&lt;/h3&gt;

&lt;p&gt;AVIF is based on the AV1 video codec and is the most efficient of the three. It handles both lossy and lossless, supports transparency, and does especially well with high-detail photos and even HDR content. At the same visual quality, AVIF files are often the smallest.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Best for:&lt;/strong&gt; squeezing the most out of large photographic images and modern sites.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Strengths:&lt;/strong&gt; excellent compression, modern feature set.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Weaknesses:&lt;/strong&gt; encoding is slower, and support is newer than WebP — so you still want fallbacks.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Quick rule of thumb
&lt;/h3&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Format&lt;/th&gt;
&lt;th&gt;Lossy / Lossless&lt;/th&gt;
&lt;th&gt;Transparency&lt;/th&gt;
&lt;th&gt;Typical use&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;JPEG&lt;/td&gt;
&lt;td&gt;Lossy&lt;/td&gt;
&lt;td&gt;No&lt;/td&gt;
&lt;td&gt;Universal fallback, photos&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;WebP&lt;/td&gt;
&lt;td&gt;Both&lt;/td&gt;
&lt;td&gt;Yes&lt;/td&gt;
&lt;td&gt;Default for most web images&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;AVIF&lt;/td&gt;
&lt;td&gt;Both&lt;/td&gt;
&lt;td&gt;Yes&lt;/td&gt;
&lt;td&gt;Best compression, modern browsers&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;PNG&lt;/td&gt;
&lt;td&gt;Lossless&lt;/td&gt;
&lt;td&gt;Yes&lt;/td&gt;
&lt;td&gt;Logos, screenshots, graphics&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Notice I kept PNG in the table: for photos it's usually overkill, but for clean graphics, logos, and screenshots with sharp edges and text, a well-optimized PNG (or indexed-color PNG-8) is still the right tool.&lt;/p&gt;

&lt;h2&gt;
  
  
  How to use them in real markup
&lt;/h2&gt;

&lt;p&gt;The cleanest pattern is the &lt;code&gt;&amp;lt;picture&amp;gt;&lt;/code&gt; element, which lets the browser pick the first format it understands and falls back to JPEG if it understands none:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;picture&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;source&lt;/span&gt; &lt;span class="na"&gt;srcset=&lt;/span&gt;&lt;span class="s"&gt;"hero.avif"&lt;/span&gt; &lt;span class="na"&gt;type=&lt;/span&gt;&lt;span class="s"&gt;"image/avif"&lt;/span&gt; &lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;source&lt;/span&gt; &lt;span class="na"&gt;srcset=&lt;/span&gt;&lt;span class="s"&gt;"hero.webp"&lt;/span&gt; &lt;span class="na"&gt;type=&lt;/span&gt;&lt;span class="s"&gt;"image/webp"&lt;/span&gt; &lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;img&lt;/span&gt;
    &lt;span class="na"&gt;src=&lt;/span&gt;&lt;span class="s"&gt;"hero.jpg"&lt;/span&gt;
    &lt;span class="na"&gt;alt=&lt;/span&gt;&lt;span class="s"&gt;"A mountain lake at sunrise"&lt;/span&gt;
    &lt;span class="na"&gt;width=&lt;/span&gt;&lt;span class="s"&gt;"1600"&lt;/span&gt;
    &lt;span class="na"&gt;height=&lt;/span&gt;&lt;span class="s"&gt;"900"&lt;/span&gt;
    &lt;span class="na"&gt;loading=&lt;/span&gt;&lt;span class="s"&gt;"lazy"&lt;/span&gt;
  &lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/picture&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The browser downloads only the first source it can decode, so you don't pay for the others. The plain &lt;code&gt;&amp;lt;img&amp;gt;&lt;/code&gt; inside is what makes this work everywhere and keeps your &lt;code&gt;alt&lt;/code&gt; text in one place.&lt;/p&gt;

&lt;h3&gt;
  
  
  Don't forget responsive sizes
&lt;/h3&gt;

&lt;p&gt;Format is only half the battle. Serving a 3000px-wide hero to a phone on a cellular connection is wasteful no matter how well it's compressed. Use &lt;code&gt;srcset&lt;/code&gt; to hand the browser appropriately sized options:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;img&lt;/span&gt;
  &lt;span class="na"&gt;src=&lt;/span&gt;&lt;span class="s"&gt;"hero-800.jpg"&lt;/span&gt;
  &lt;span class="na"&gt;srcset=&lt;/span&gt;&lt;span class="s"&gt;"hero-800.jpg 800w, hero-1200.jpg 1200w, hero-1600.jpg 1600w"&lt;/span&gt;
  &lt;span class="na"&gt;sizes=&lt;/span&gt;&lt;span class="s"&gt;"(max-width: 600px) 100vw, 50vw"&lt;/span&gt;
  &lt;span class="na"&gt;alt=&lt;/span&gt;&lt;span class="s"&gt;"A mountain lake at sunrise"&lt;/span&gt;
  &lt;span class="na"&gt;loading=&lt;/span&gt;&lt;span class="s"&gt;"lazy"&lt;/span&gt;
&lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Protect your LCP
&lt;/h3&gt;

&lt;p&gt;For the single largest above-the-fold image (often the hero), a couple of small tweaks help the browser prioritize it:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;img&lt;/span&gt; &lt;span class="na"&gt;src=&lt;/span&gt;&lt;span class="s"&gt;"hero.avif"&lt;/span&gt; &lt;span class="na"&gt;alt=&lt;/span&gt;&lt;span class="s"&gt;"..."&lt;/span&gt; &lt;span class="na"&gt;fetchpriority=&lt;/span&gt;&lt;span class="s"&gt;"high"&lt;/span&gt; &lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And reserve space with &lt;code&gt;width&lt;/code&gt; and &lt;code&gt;height&lt;/code&gt; attributes so the layout doesn't shift while the image loads — that helps both performance and Cumulative Layout Shift.&lt;/p&gt;

&lt;h2&gt;
  
  
  Picking quality settings
&lt;/h2&gt;

&lt;p&gt;Modern formats are forgiving, and most people over-estimate the quality they need. A sensible starting point:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;JPEG:&lt;/strong&gt; quality around 60–75&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;WebP:&lt;/strong&gt; quality around 65–75&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;AVIF:&lt;/strong&gt; quality around 45–55 (its scale behaves differently, lower numbers go further)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The right method is always the same: make a copy, try a few settings, and compare at 100% zoom. Push compression until you can just start to notice a difference, then back off one notch. The goal is the smallest file that still looks indistinguishable to a normal viewer — not the highest possible number.&lt;/p&gt;

&lt;h2&gt;
  
  
  A note on privacy
&lt;/h2&gt;

&lt;p&gt;One detail people overlook: many online compressors upload your files to a server to process them, and some retain copies for a period. If you're handling confidential designs, client work, or personal photos, that's a real consideration. A browser-based compressor that runs entirely client-side (using WebAssembly) never uploads the file in the first place, which removes that class of risk entirely.&lt;/p&gt;

&lt;p&gt;I've been building exactly this — &lt;a href="https://eltorin.com" rel="noopener noreferrer"&gt;Eltorin&lt;/a&gt; is a free image compressor that does all the processing locally in your browser with no uploads, no signup, and no artificial file-count or size quotas. It handles JPEG, PNG, WebP, and AVIF, and it's a handy way to experiment with the quality settings above without sending anything anywhere.&lt;/p&gt;

&lt;h2&gt;
  
  
  The takeaway
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Default to WebP&lt;/strong&gt;, use &lt;strong&gt;AVIF&lt;/strong&gt; for maximum savings on modern browsers, and keep a &lt;strong&gt;JPEG&lt;/strong&gt; fallback.&lt;/li&gt;
&lt;li&gt;Use &lt;code&gt;&amp;lt;picture&amp;gt;&lt;/code&gt; for format negotiation and &lt;code&gt;srcset&lt;/code&gt; for responsive sizes.&lt;/li&gt;
&lt;li&gt;Reserve image dimensions, lazy-load below the fold, and mark your LCP image with &lt;code&gt;fetchpriority="high"&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Tune quality by eye — the smallest file that looks identical is the winner.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Get the images right, and that stubborn performance score usually starts taking care of itself.&lt;/p&gt;




</description>
      <category>performance</category>
      <category>beginners</category>
      <category>frontend</category>
      <category>webdev</category>
    </item>
    <item>
      <title>Eltorin — Free private image compressor running locally in your browser</title>
      <dc:creator>zhiwei wang</dc:creator>
      <pubDate>Thu, 29 Oct 2026 13:41:03 +0000</pubDate>
      <link>https://dev.to/zhiwei_wang_a8e83fd894cf9/eltorin-free-private-image-compressor-running-locally-in-your-browser-3hfc</link>
      <guid>https://dev.to/zhiwei_wang_a8e83fd894cf9/eltorin-free-private-image-compressor-running-locally-in-your-browser-3hfc</guid>
      <description>&lt;p&gt;Eltorin is a free image compression tool.&lt;br&gt;
All images are processed &lt;strong&gt;locally inside your browser&lt;/strong&gt;, your files never upload to any server.&lt;br&gt;
✅ No signup&lt;br&gt;
✅ Unlimited compression&lt;br&gt;
✅ Support batch process up to 100 images&lt;br&gt;
Built for designers and developers who care about privacy.&lt;/p&gt;

&lt;p&gt;Check it out: &lt;a href="https://eltorin.com" rel="noopener noreferrer"&gt;https://eltorin.com&lt;/a&gt;&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>javascript</category>
      <category>frontend</category>
      <category>privacy</category>
    </item>
  </channel>
</rss>
