At work, we use Brotli (using the Node builtin zlib) to compress these large .json files to .json.br files. When using zlib.brotliCompress you can set options to override the quality number. Here's an example of it at quality 6:


import { promisify } from 'util'
import zlib from 'zlib'
const brotliCompress = promisify(zlib.brotliCompress)

const options = {
  params: {
    [zlib.constants.BROTLI_PARAM_MODE]: zlib.constants.BROTLI_MODE_TEXT,
    [zlib.constants.BROTLI_PARAM_QUALITY]: 6,
  },
}

export async function compress(data) {
  return brotliCompress(data, options)
}

But what if you mess with that number. Surely, the files will become smaller, but at what cost? Well, I wrote a Node script that measured how long it would take to compress 6 large (~25MB each) .json file synchronously. Then, I put them into a Google spreadsheet and voila:

Size

Total size per level

Time

Total seconds per level

Miles away from rocket science but I thought it was cute to visualize as a way of understanding the quality option.

Comments

Eric

That's super interesting! So if time and compute is not a limiting issue one can get quite some smaler files!
I wonder if this this impacts decompression in any way? 🤔

a b

Could you make the results available as text as well?

Your email will never ever be published.

Previous:
How to string pad a string in Python with a variable October 19, 2021 Python
Next:
Sort a JavaScript array by some boolean operation December 2, 2021 JavaScript
Related by category:
How to SSG a Vite SPA April 26, 2025 JavaScript
Switching from Next.js to Vite + wouter July 28, 2023 JavaScript, Node
fnm is much faster than nvm. December 28, 2023 Node
An ideal pattern to combine React Router with TanStack Query November 18, 2024 JavaScript
Related by keyword:
Fastest Redis configuration for Django May 11, 2017 Python, Linux, Web development, Django
Find out all localStorage keys and their value sizes July 13, 2019 Web development, JavaScript
csso and django-pipeline February 28, 2018 Python, Django, JavaScript
Experimenting with Guetzli May 24, 2017 Linux, Web development, macOS