Skip to content

USWDS - Core: Replace receptor library "behavior" with custom implementation#6175

Merged
heymatthenry merged 5 commits into
uswds:replace-receptorfrom
aduth:aduth-rm-receptor-behavior
Jun 9, 2025
Merged

USWDS - Core: Replace receptor library "behavior" with custom implementation#6175
heymatthenry merged 5 commits into
uswds:replace-receptorfrom
aduth:aduth-rm-receptor-behavior

Conversation

@aduth

@aduth aduth commented Nov 1, 2024

Copy link
Copy Markdown
Contributor

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/behavior with 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:

npm exec gulp unitTests

Review experience for individual components within the Storybook preview at http://localhost:6006

aduth added 2 commits November 1, 2024 09:22
- 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
@mejiaj mejiaj added this to the USWDS release: January 2025 milestone Jan 3, 2025
@mejiaj mejiaj changed the base branch from develop to replace-receptor January 14, 2025 14:11
@mejiaj mejiaj requested a review from a team as a code owner January 14, 2025 14:11
@dct2023

dct2023 commented Feb 7, 2025

Copy link
Copy Markdown

@mlloydbixal Adding you as a reviewer for this to get us unblocked on #6291

@heymatthenry heymatthenry merged commit 8c0c7b5 into uswds:replace-receptor Jun 9, 2025
1 check passed
@github-project-automation github-project-automation Bot moved this from Peer Review to Fed Final Review in USWDS Core Project Data Jun 9, 2025
@heymatthenry heymatthenry mentioned this pull request Jun 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

5 participants