USWDS - Core: Replace receptor library "behavior" with custom implementation#6175
Merged
heymatthenry merged 5 commits intoJun 9, 2025
Merged
Conversation
- Reduces size of behavior by 66%, minimal component import (accordion) by 50% - Narrows scope to features in use - Avoid baked-in polyfills not necessary for current browser supports - Remove third-party dependencies to reduce maintenance overhead and security vulnerability attack surface area - Add TypeScript annotations for IDEs supporting code autocompletion (e.g. VS Code) ``` echo "import './packages/usa-banner/src/index.js'" | npx esbuild --bundle --minify | brotli-size ``` Before: 1.84 kB After: 896 B Diff: -944 B (-51.3%) ``` echo "import './packages/uswds-core/src/js/utils/behavior'" | npx esbuild --bundle --minify | brotli-size ``` Before: 1.43 kB After: 473 B Diff: -957 B (-66.9%)
Review feedback from uswds#6172
|
@mlloydbixal Adding you as a reviewer for this to get us unblocked on #6291 |
Merged
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
Reduced the JavaScript bundle size. By optimizing the implementation of core component code, overall JavaScript sizes are reduced.
Breaking change
This is not a breaking change (see #5793 for edge-cases).
Related pull requests
Split from #5793, to simplify review.
Includes additional inline code comments based on review feedback from that pull request (see abdbea1).
Preview link
N/A
Problem statement
See #5793
Solution
Replace use of
receptor/behaviorwith equivalent custom implementation.Refer to #5793 for full details of expected performance impact following complete removal of
receptor.Testing and review
Verify all unit tests pass:
Review experience for individual components within the Storybook preview at http://localhost:6006