<?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: Piotr Suchanek</title>
    <description>The latest articles on DEV Community by Piotr Suchanek (@daverdalas).</description>
    <link>https://dev.to/daverdalas</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%2F4260987%2F08e427e0-effc-44ec-be75-2b57ee4bd6bb.jpg</url>
      <title>DEV Community: Piotr Suchanek</title>
      <link>https://dev.to/daverdalas</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/daverdalas"/>
    <language>en</language>
    <item>
      <title>libdeflate in WebAssembly: 6% smaller than fflate, faster at level 6</title>
      <dc:creator>Piotr Suchanek</dc:creator>
      <pubDate>Mon, 23 Nov 2026 16:21:57 +0000</pubDate>
      <link>https://dev.to/daverdalas/libdeflate-in-webassembly-6-smaller-than-fflate-faster-at-level-6-35nk</link>
      <guid>https://dev.to/daverdalas/libdeflate-in-webassembly-6-smaller-than-fflate-faster-at-level-6-35nk</guid>
      <description>&lt;p&gt;Konvetto's Compress PDF tool runs entirely in the browser. Most of a PDF is Flate streams (zlib), so whichever deflate encoder you ship sets the floor for the output size. We started with fflate at level 9, the usual choice in JS. It is fast and good, but it stops where zlib stops.&lt;/p&gt;

&lt;p&gt;libdeflate goes further. Its levels 10 to 12 use a near-optimal parser, and on large inputs they come close to Zopfli in a fraction of the time. We wanted a small wasm build with no JS glue that matches native output byte for byte, so we made one.&lt;/p&gt;

&lt;h3&gt;
  
  
  The build
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;libdeflate 1.26, Emscripten 7.0.1, &lt;code&gt;-O3 -flto&lt;/code&gt;, emmalloc.&lt;/li&gt;
&lt;li&gt;One standalone &lt;code&gt;.wasm&lt;/code&gt; file with no JS glue and no threads.&lt;/li&gt;
&lt;li&gt;The output is byte-identical to native libdeflate at every level.&lt;/li&gt;
&lt;li&gt;API: &lt;code&gt;await init()&lt;/code&gt; (or &lt;code&gt;initSync&lt;/code&gt; in a worker), then &lt;code&gt;zlib(bytes, 12)&lt;/code&gt;, &lt;code&gt;gzip&lt;/code&gt;, &lt;code&gt;deflate&lt;/code&gt; and the three decoders.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Numbers (Silesia corpus, 211.9 MB, one thread)
&lt;/h3&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Encoder&lt;/th&gt;
&lt;th&gt;Size&lt;/th&gt;
&lt;th&gt;Time&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;fflate 9&lt;/td&gt;
&lt;td&gt;69.13 MB&lt;/td&gt;
&lt;td&gt;10.7 s&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;pako 9&lt;/td&gt;
&lt;td&gt;68.17 MB&lt;/td&gt;
&lt;td&gt;16.0 s&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;node:zlib 9&lt;/td&gt;
&lt;td&gt;67.64 MB&lt;/td&gt;
&lt;td&gt;12.8 s&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;CompressionStream&lt;/td&gt;
&lt;td&gt;68.22 MB&lt;/td&gt;
&lt;td&gt;5.3 s&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;libdeflate-wasm 6&lt;/td&gt;
&lt;td&gt;67.51 MB&lt;/td&gt;
&lt;td&gt;2.6 s&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;libdeflate-wasm 12&lt;/td&gt;
&lt;td&gt;64.68 MB&lt;/td&gt;
&lt;td&gt;41.2 s&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Zopfli, 15 iterations&lt;/td&gt;
&lt;td&gt;64.71 MB&lt;/td&gt;
&lt;td&gt;727 s&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F6hdnig7itc5cs35i62f3.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F6hdnig7itc5cs35i62f3.png" alt="Scatter chart of compressed size against time on the Silesia corpus: libdeflate-wasm 6, 9 and 12 against fflate, pako, node:zlib, CompressionStream and Zopfli" width="800" height="453"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Level 6 beats every zlib-level-9 encoder on both size and time. Level 12 matches Zopfli's size about 18 times faster. Level 12 is slow on 200 MB, but PDF streams are small, and the tool runs it in a Web Worker, so the page stays responsive.&lt;/p&gt;

&lt;h3&gt;
  
  
  What it did for PDFs
&lt;/h3&gt;

&lt;p&gt;Compress PDF repacks every Flate stream (text, fonts, vector drawings) at level 12. Nothing in them changes, they are just written more tightly. The photos go through their own JPEG pass. The end result against iLovePDF, Smallpdf and PDF24 on seven public PDFs, with the files and the method, is here: &lt;a href="https://konvetto.com/pdf-compressor-comparison" rel="noopener noreferrer"&gt;https://konvetto.com/pdf-compressor-comparison&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Try it
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Package: &lt;code&gt;npm i libdeflate-wasm&lt;/code&gt; (MIT), &lt;a href="https://github.com/Konvetto/libdeflate-wasm" rel="noopener noreferrer"&gt;https://github.com/Konvetto/libdeflate-wasm&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;The tool that uses it: &lt;a href="https://konvetto.com/pdf/compress-pdf" rel="noopener noreferrer"&gt;https://konvetto.com/pdf/compress-pdf&lt;/a&gt; (no upload)&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>webassembly</category>
      <category>javascript</category>
      <category>performance</category>
      <category>opensource</category>
    </item>
  </channel>
</rss>
