Skip to content

Conversation

heymatthenry
Copy link
Contributor

@heymatthenry heymatthenry commented Jun 9, 2025

Summary

This PR removes Receptor dependency and reimplements its functionality in first-party code. The only non-dev dependency is now Lit, which is only necessary if using the new web component banner variant.

Breaking change

⚠️ This is potentially a breaking change.

There are some very niche edge cases highlighted in a separate PR (#5793) that are worth noting here, but if you are only using the public APIs of USWDS components rather than certain internals (as described in the linked PR), breakages are unlikely.

Related issue

Closes #6291

Major changes / Related PRs

The specific replacements/re-implementations for the receptor library functionality are described in greater detail in:

Dependency name Previous version New version
Receptor 1.0.0 --

Acknowledgments

Huge thanks to @aduth for doing more than the lion's share of the work on this, and also to our great USWDS alumni, including @mejiaj , @mahoneycm, @amyleadem, @mandylloyd for reviewing and providing feedback on this work along the way.

aduth and others added 12 commits November 1, 2024 08:49
- 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 #6172
USWDS - Core: Replace receptor library "once" with once option for event listeners
USWDS - Core: Replace receptor library "ignore" with Element#contains
USWDS - Core: Replace receptor library "behavior" with custom implementation
@heymatthenry heymatthenry marked this pull request as ready for review June 10, 2025 15:48
@heymatthenry heymatthenry merged commit ad9ffc1 into develop Jun 12, 2025
4 checks passed
@heymatthenry heymatthenry deleted the replace-receptor branch June 12, 2025 15:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

USWDS - Core: Remove receptor dependency
3 participants