Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consider using zopfli to generate .gz files #402

Open
twm opened this issue Jul 5, 2022 · 3 comments
Open

Consider using zopfli to generate .gz files #402

twm opened this issue Jul 5, 2022 · 3 comments

Comments

@twm
Copy link

twm commented Jul 5, 2022

Description

The Zopfli compressor generates gzip-compatible compressed files smaller than zlib, and often pretty close to Brotli. For example I use the Python bindings to compress some web assets here:

ORIGINAL   ZOPFLI    (.gz)  BROTLI   (.br)  FILE
---------  ---------------  --------------  ------------------------------------------
    6,138      1,686   27%     1,398   23%  normalize-8.0.1.css
  318,964    161,987   51%   141,848   44%  inconsolata-33dd95333e9e.ttf
      515        199   39%       178   35%  fonts-8e4fe55c0023.css
   22,141      4,573   21%     4,037   18%  main-b75bac5769ba.css
    9,310      2,512   27%     2,355   25%  main-b75bac5769ba.css.map
    5,805      1,149   20%     1,043   18%  icon-bd3da638f8c2.svg
    2,544      1,056   42%       976   38%  lettertype-dc874be920ee.svg
    8,957      1,940   22%     1,879   21%  logotype-a492afd710d0.svg
   24,838      4,849   20%     4,555   18%  icon-4a76ea6aede6.ico

The main downside is that Zopfli is much slower than zlib, like Brotli.

@adamchainz
Copy link
Collaborator

It is slower... wikipedia:

Under default settings, the output of Zopfli is typically 3–8% smaller than zlib's maximum compression, but takes around 80 times longer.

Whitenoise already adds a considerable overhead to deploys by doing so much work compressing up front, in serial (often including third party files that aren't served). I wouldn't want to slow it down further for savings when Brotli is already supported, and widely supported by browsers.

It could perhaps be an option, but I'd like to see more evidence that it's really desirable.

Is zopfli really the official library? It only has 12 stars, doesn't seem to be so popular.

@twm
Copy link
Author

twm commented Jul 5, 2022

Whitenoise already adds a considerable overhead to deploys by doing so much work compressing up front, in serial (often including third party files that aren't served). I wouldn't want to slow it down further for savings when Brotli is already supported, and widely supported by browsers.

It could perhaps be an option, but I'd like to see more evidence that it's really desirable.

Agreed, there's a tradeoff here. I doubt it's worthwhile for large files. I just wanted to make sure you were aware it exists. Unfortunately I don't have any data on .gz vs .br hit rates to share.

Is zopfli really the official library? It only has 12 stars, doesn't seem to be so popular.

The only other one I've found is pyzopfli which appears unmaintained. IIRC I selected zopfli because it:

  1. Provides wheels
  2. Appeared to be maintained by Googlers (like Zopfli itself), though this no longer seems to be the case

@adamchainz
Copy link
Collaborator

Okay. I think the best course of action right now is to leave this open, and if others show support for the feature then we can look into it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants