Repository navigation
build: reduce bundle size with CSS compaction and two Terser passes - #484
Merged
Merged
Conversation
Deploying podnotes with
|
| Latest commit: |
466c1c7
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://25827fdb.podnotes.pages.dev |
| Branch Preview URL: | https://build-size-levers.podnotes.pages.dev |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Reduce the production bundle by 328 gzip bytes (measured against master bdf3b82 by the independent verifier V-484) with a second Terser compression pass and conservative CSS formatting compaction. Headroom becomes 638 gzip bytes and 7,632 raw bytes. Both budgets remain unchanged.
The author's original measurement against master eafb24b was -347 (passes 2: -264, CSS: -79); V-484 reproduced it exactly. The smaller saving on current master comes from the code #479 and #482 added (compressor context and longer scoped class ids), not from a change in the levers.
Each option was built five times with identical bytes. Savings are small because Svelte already removes most CSS formatting and gzip compresses repeated formatting well. A second Terser pass removes code exposed by the first pass. Later passes produce worse gzip results. Combined gzip savings are not additive.
The CSS helper preserves selectors, values, custom-property spacing, and inline comments. Production getter reads, ES2020, the no-tagged-template rule, and the hash algorithm remain intact. Short hashes were rejected because they weaken collision resistance. Full-strength compact encodings increased gzip size. No source or dependency files change.
The evidence archive contains the complete per-lever table, rejected experiments, rerunnable measurement scripts, raw logs, mutation results, and screenshots.
Measurements, verification logs, and pixel evidence
Verification
All commands ran with Node 22.23.2 through
fnm exec --using 22.npm run lint,npm run format:check,npm run typecheck, andnpm run buildpassed.npm run testpassed, 124 files and 2,613 tests. Both Svelte checks found zero warnings or errors.npm run test:toolingpassed, 4 files and 30 tests.npm run docs:buildpassed, 18 pages and 112 legacy fragments.npm run sizepassed at 320,419 raw bytes and 101,490 gzip bytes.npm run test:e2epassed on a fresh vault in Obsidian 1.14.4 on Linux, 28 files and 207 tests. A full 1.13.7 run passed 198 tests before the final test-only master merge. All 39 tests in its five changed E2E files then passed on 1.13.7 against the identical bundle. No unexpected renderer errors occurred, and cleanup confirmed no remaining instance processes.Five plausible wrong changes each failed a test before restoration:
buildOptions.test.tscompactCss.test.tscalcsubtractioncompactCss.test.tscompactCss.test.tspure_getters: truebuildOptions.test.ts, getter read count becomes zeroIndependent reviews completed with Claude Fable 5.1 and GPT-6 Astra. The production-build test now sets and asserts production mode after Astra caught Vitest's default test environment. A fresh review accepted the fix, and Claude Opus 5.5 verified the artifact, size, syntax floor, and focused tooling tests.
Release impact
None. No settings, storage, API, URI, or migration changes. No user-documentation changes are needed.
Note
Reduce bundle size with CSS compaction and two Terser passes
Adds
compactCssin compact-css.ts, a PostCSS-based serializer that removes formatting-only whitespace while preserving comments, quoted values, and custom-property spacing.compactCssafter comment stripping in production mode only; development builds are unchanged.compactCsstoken-preservation cases in compactCss.test.ts if styles regress.Macroscope summarized 466c1c7.