You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
perf: precompress public assets at brotli quality 10 - #5198
📖 Documentation (updates to the documentation, readme, or JSdoc annotations)
🐞 Bug fix (a non-breaking change that fixes an issue)
👌 Enhancement (improving an existing functionality like performance)
✨ New feature (a non-breaking change that adds functionality)
🧹 Chore (updates to the build process or auxiliary tools and libraries)
⚠️ Breaking change (fix or feature that would cause existing functionality to change)
📚 Description
when public asset compression is enabled, brotli at quality 11 costs quite a lot.
here are some cold nitro build runs with 185 kB of /_nuxt output (6 files) and with 2.6 MB of production assets from a larger site (107 files):
no precompression
quality 11
quality 10
quality 9
185 kB of assets
264 ms
437 ms
336 ms
270 ms
2.6 MB of assets
272 ms
1737 ms
849 ms
402 ms
brotli bytes, 185 kB
59.9 kB
60.8 kB
64.2 kB
brotli bytes, 2.6 MB
639 kB
650 kB
690 kB
quality 10 keeps about 98% of the saving for a third of the time, so this PR makes it the default and adds brotliQuality for anyone who would rather have the extra percent:
this PR also includes a bug fix - the brotli options were being passed one level too high (brotliCompress(buffer, params) instead of { params }). this meant that the quality, the text mode and the size hint were all ignored and the encoder used its own defaults. so instead this PR passes them under params.
No actionable comments were generated in the recent review.
Walkthrough
Public asset compression now accepts a configurable Brotli quality, defaulting to 10. The documentation describes the setting and its 0–11 range. Unit tests check output with a configured quality and with the default.
Changes: Brotli quality configuration
Layer / File(s)
Summary
Brotli quality option and documentation src/types/config.ts, docs/3.config/4.assets.md, docs/1.docs/50.assets.md
CompressOptions adds optional brotliQuality. The documentation describes its default of 10, range of 0–11, and an example setting it to 11.
Apply and test Brotli quality src/utils/compress.ts, test/unit/compress-assets.test.ts
The utility resolves compression settings before processing files and applies the configured Brotli quality, defaulting to 10. Tests compare compressed output with Node Brotli output for configured and default quality.
Public asset Brotli compression now defaults to quality 10, which builds faster, and brotliQuality allows quality 11 when needed. No merge-blocking risk remains.
Pre-merge checks: 4
Check name
Status
Explanation
Title check
The title "perf: precompress public assets at brotli quality 10" follows the conventional commits format with a valid type prefix. It states the main change: public assets are precompressed with Brotl…
Description check
The description covers the problem (Brotli quality 11 is slow), benchmark tables comparing quality levels, the new default of quality 10, the new brotliQuality option with an example, and the bug fix …
Linked Issues check
Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check
Check skipped because no linked issues were found for this pull request.
Full details: Title check
Explanation
The title "perf: precompress public assets at brotli quality 10" follows the conventional commits format with a valid type prefix. It states the main change: public assets are precompressed with Brotli at quality 10, which matches the default change in src/utils/compress.ts and the new brotliQuality option.
Full details: Description check
Explanation
The description covers the problem (Brotli quality 11 is slow), benchmark tables comparing quality levels, the new default of quality 10, the new brotliQuality option with an example, and the bug fix where Brotli options were passed at the wrong level. It relates directly to the changeset.
Finishing Touches
Generate unit tests (beta)
Create a new PR
Fix failing CI checks
Create a new PR
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
File: No configuration file from this repository applied
Commit: Unavailable
Layers: Organization UI
Review profile: CHILL
Plan: Advanced
Run ID: 0bda38c1-0e08-4529-b9ba-d418ba35854e
Commits
Reviewing files that changed from the base of the PR and between 925c135 and 4a79d54.
Files selected for processing: 5
docs/1.docs/50.assets.md
docs/3.config/4.assets.md
src/types/config.ts
src/utils/compress.ts
test/unit/compress-assets.test.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🔗 Linked issue
❓ Type of change
📚 Description
when public asset compression is enabled, brotli at quality 11 costs quite a lot.
here are some cold
nitro buildruns with 185 kB of/_nuxtoutput (6 files) and with 2.6 MB of production assets from a larger site (107 files):quality 10 keeps about 98% of the saving for a third of the time, so this PR makes it the default and adds
brotliQualityfor anyone who would rather have the extra percent:Note
this PR also includes a bug fix - the brotli options were being passed one level too high (
brotliCompress(buffer, params)instead of{ params }). this meant that the quality, the text mode and the size hint were all ignored and the encoder used its own defaults. so instead this PR passes them underparams.📝 Checklist