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

precompress - please add configuration #10789

Open
HummingMind opened this issue Sep 27, 2023 · 8 comments
Open

precompress - please add configuration #10789

HummingMind opened this issue Sep 27, 2023 · 8 comments

Comments

@HummingMind
Copy link

Describe the problem

Hello,
Precompress could use some configuration settngs for the adapters that support it.

Thank you!

Describe the proposed solution

  1. Allow to disable gzip or brotli. Something like {gzip: false, brotli: true}
  2. Add a minimum size of the assets that should be compressed. For example, do not compress anything under 1024 bytes. Compressing these tiny files can actually make them larger. Something like {minSize: 1024}
  3. Allow to control which assets are compressed. Something like {formats: [html, svg, js, css]}

Alternatives considered

No response

Importance

nice to have

Additional Information

No response

@flo-at
Copy link

flo-at commented Jan 16, 2024

I just found this issue while trying to find out how to configure the precompress task. Instead of (or in addition to) the minimum size option, imo an option to delete the files that end up being larger than their uncompressed version would be better. The minimum size is a guessing game and it depends on the content of the file, too.

@benmccann
Copy link
Member

Allow to control which assets are compressed. Something like {formats: [html, svg, js, css]}

What's the usecase for that?

@benmccann
Copy link
Member

More ideas for configuration here: #1693 (comment)

I'd rather keep things on the simple side though

@HummingMind
Copy link
Author

HummingMind commented Mar 6, 2024

Allow to control which assets are compressed. Something like {formats: [html, svg, js, css]}

What's the usecase for that?

Probably not as important as # 1 and # 2, but it would allow for additional flexibility.

Looks like html, js, json, css, svg, xml are currently compressed. There may be additional asset fromats that could benefit. (.txt or .csv) for example. Probably always better to let the user control and override the default choices or add additional formats.

Thank you!

@benmccann
Copy link
Member

Looks like html, js, json, css, svg, xml are currently compressed.

Actually the code has ['.html', '.js', '.mjs', '.json', '.css', '.svg', '.xml', '.wasm']. Yes, it could make sense to make this configurable.

Allow to disable gzip or brotli. Something like {gzip: false, brotli: true}

I guess you might not need to create gzip if you don't support older browsers, but why would you want to be able to disable brotli?

@HummingMind
Copy link
Author

Looks like html, js, json, css, svg, xml are currently compressed.

Actually the code has ['.html', '.js', '.mjs', '.json', '.css', '.svg', '.xml', '.wasm']. Yes, it could make sense to make this configurable.

Allow to disable gzip or brotli. Something like {gzip: false, brotli: true}

I guess you might not need to create gzip if you don't support older browsers, but why would you want to be able to disable brotli?

Personally, I am using brotli and would not want to disable it. Not sure if anyone else has a use case for doing that. I would be OK with having the option to disable only gzip.

@DavidPHH
Copy link

I have to disable precompress entirely because Bun doesn't have zlib.createBrotliCompress implemented yet (issue)

Would be neat to have the option to just disable brotli.

@jasongitmail
Copy link

jasongitmail commented Aug 20, 2024

Useful site to estimate KB savings for your site based on compression level:
https://tools.paulcalvano.com/compression.php
https://tools.paulcalvano.com/compression-tester/

For my SvelteKit site, max brotli would save 15-20% over Cloudflare's default brotli level (4). zstd would be even more.

@DavidPHH bun supports now via node:zlib.

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

No branches or pull requests

7 participants