question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

qwik: enable brotli compression for larger files

See original GitHub issue

Is your feature request related to a problem?

having a look at the build logs and network tab we have at least one bigger file (~16kb gzipped) which is served with gzip compression to our clients and could be even better compressed using brotli (br). in our file it would be a reduction of ~2kb.

Bildschirmfoto 2022-10-24 um 15 04 10

Describe the solution you’d like

file sizes above a configurable threshold should be compressed using br instead of gzip

Describe alternatives you’ve considered

theres no alternative 😄

Additional context

No response

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:7 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
manucorporatcommented, Oct 25, 2022

it makes sense, but i would look into: https://github.com/vbenjs/vite-plugin-compression

Since this output is controlled by vite! if this plugin does not work, then maybe there is something we can fix in our side 😃

0reactions
zanettincommented, Oct 25, 2022

thanks again 🙏

of corse you would go with a vite plugin 😄 i’ve mentioned our current plain react/webpack setup not a solution for qwik.

btw: netlify does brotli compression automatically w/o any preconfig: https://www.netlify.com/blog/2020/05/20/gain-instant-performance-boosts-as-brotli-comes-to-netlify-edge/

for express we would still need to use your plugin to get the br, gz files and then serve them using the express-static-gzip lib. gave it a spin quickly and the only “ugly” thing is, that we need to compress br and gz sequentially:

// vite.config.ts
export default defineConfig(() => {
  return {
    plugins: [
      ...
      viteCompression({ algorithm: "brotliCompress" }), // precompress brotli
      viteCompression(), // precompress gzip
      ...
    ],
  };
});

build output

vite v3.1.8 building for production...
✓ 214 modules transformed.
dist/q-manifest.json        21.81 KiB
dist/build/q-0d172b11.js    0.06 KiB / gzip: 0.07 KiB
dist/build/q-93708e5b.js    4.64 KiB / gzip: 2.26 KiB
dist/build/q-fa4bbbcc.js    0.26 KiB / gzip: 0.22 KiB
dist/build/q-a6747fb6.js    0.19 KiB / gzip: 0.17 KiB
dist/build/q-7c5ad0b1.js    1.49 KiB / gzip: 0.83 KiB
dist/build/q-3ec59b3e.js    0.83 KiB / gzip: 0.49 KiB
dist/build/q-957da244.js    0.50 KiB / gzip: 0.27 KiB
dist/build/q-80d26eea.js    1.00 KiB / gzip: 0.51 KiB
dist/build/q-80149d1f.js    0.20 KiB / gzip: 0.16 KiB
dist/build/q-bab62a4e.js    0.46 KiB / gzip: 0.31 KiB
dist/build/q-6ec283e2.js    0.11 KiB / gzip: 0.11 KiB
dist/build/q-29ac8fac.js    0.29 KiB / gzip: 0.22 KiB
dist/build/q-1aecd977.js    1.06 KiB / gzip: 0.55 KiB
dist/build/q-39217e13.js    1.34 KiB / gzip: 0.67 KiB
dist/build/q-2b3586eb.js    0.22 KiB / gzip: 0.17 KiB
dist/service-worker.js      2.48 KiB / gzip: 1.18 KiB
dist/build/q-74633e43.js    1.55 KiB / gzip: 0.72 KiB
dist/build/q-16137215.js    0.20 KiB / gzip: 0.16 KiB
dist/build/q-87008f64.js    0.21 KiB / gzip: 0.18 KiB
dist/build/q-e14c1274.js    0.83 KiB / gzip: 0.51 KiB
dist/build/q-08e0e556.js    0.64 KiB / gzip: 0.38 KiB
dist/build/q-93a20b72.js    0.52 KiB / gzip: 0.35 KiB
dist/build/q-0648ee28.js    0.51 KiB / gzip: 0.35 KiB
dist/build/q-255e8738.js    0.77 KiB / gzip: 0.49 KiB
dist/build/q-849bb508.js    0.77 KiB / gzip: 0.44 KiB
dist/build/q-df4be8e8.css   0.04 KiB / gzip: 0.06 KiB
dist/build/q-10300dfc.js    1.42 KiB / gzip: 0.77 KiB
dist/build/q-d9cf3cff.js    0.32 KiB / gzip: 0.22 KiB
dist/build/q-b92d17a8.css   0.84 KiB / gzip: 0.48 KiB
dist/build/q-8bb6df3d.js    1.39 KiB / gzip: 0.76 KiB
dist/build/q-9d798d0b.css   0.39 KiB / gzip: 0.23 KiB
dist/build/q-9d50248b.css   0.33 KiB / gzip: 0.23 KiB
dist/build/q-6bad50e3.js    40.40 KiB / gzip: 16.27 KiB

✨ [vite-plugin-compression]:algorithm=gzip - compressed file successfully: 
dist/build/q-10300dfc.js.gz   1.42kb / gzip: 0.77kb
dist/build/q-1aecd977.js.gz   1.06kb / gzip: 0.55kb
dist/build/q-39217e13.js.gz   1.34kb / gzip: 0.67kb
dist/build/q-74633e43.js.gz   1.55kb / gzip: 0.72kb
dist/build/q-8bb6df3d.js.gz   1.39kb / gzip: 0.76kb
dist/build/q-7c5ad0b1.js.gz   1.49kb / gzip: 0.83kb
dist/build/q-93708e5b.js.gz   4.64kb / gzip: 2.26kb
dist/service-worker.js.gz     2.48kb / gzip: 1.18kb
dist/q-manifest.json.gz       21.81kb / gzip: 3.22kb
dist/build/q-6bad50e3.js.gz   40.40kb / gzip: 16.25kb



✨ [vite-plugin-compression]:algorithm=brotliCompress - compressed file successfully: 
dist/build/q-39217e13.js.br   1.34kb / brotliCompress: 0.55kb
dist/build/q-10300dfc.js.br   1.42kb / brotliCompress: 0.68kb
dist/build/q-74633e43.js.br   1.55kb / brotliCompress: 0.64kb
dist/build/q-7c5ad0b1.js.br   1.49kb / brotliCompress: 0.73kb
dist/build/q-1aecd977.js.br   1.06kb / brotliCompress: 0.49kb
dist/service-worker.js.br     2.48kb / brotliCompress: 1.07kb
dist/build/q-8bb6df3d.js.br   1.39kb / brotliCompress: 0.65kb
dist/build/q-93708e5b.js.br   4.64kb / brotliCompress: 2.02kb
dist/q-manifest.json.br       21.81kb / brotliCompress: 2.79kb
dist/build/q-6bad50e3.js.br   40.40kb / brotliCompress: 14.62kb



✓ Built client modules
✓ Built server (ssr) modules
✓ Type checked

✨  Done in 2.57s.

if you think it is something for your node/express defaults let me know and i’ll have a look at it when the new adapter handling is shipped. otherwise thanks for all your answers and patience 🙏

Read more comments on GitHub >

github_iconTop Results From Across the Web

Brotli Compression: A Fast Alternative to GZIP Compression
Brotli has a better compression ratio (i.e. it produces smaller compressed files) across every level of compression. While GZIP does beat Brotli ......
Read more >
How to Enable Brotli Compression for Your Site - YouTube
Ready to look into Brotli compression and see how to enable it on your own site? 💪 The answers are here 💥 👉...
Read more >
Introducing Support for Brotli Compression - .NET Blog
Summary. Brotli is a relatively new compression algorithm. It's quite beneficial for web clients, with decompression performance comparable to ...
Read more >
'You can't use Brotli for dynamic content'
I enabled this on a static asset management tool a while ago and it took several times longer to generate compressed files than...
Read more >
Brotli and Static Compression
In this short article, you'll get to learn about setting up your site to statically compress files for optimal compression performance, ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found