USWDS: Remove JavaScript destructuring example from README #5928
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
Improve documentation for JavaScript customization. Updated code snippets to ensure optimal build size.
Breaking change
This is not a breaking change.
Related issue
Tangentially related to #4515 . #4515 could enable optimized top-level imports using a syntax similar to the code being removed here, if combined with
package.json
sideEffects
tree-shaking.Related Slack discussion in USWDS public Slack: https://gsa-tts.slack.com/archives/C3F14AHSQ/p1715273540567929
Problem statement
As a developer interested in reducing the size of the JavaScript produced by USWDS, I expect that USWDS's documentation for customizing JavaScript will produce code with the intended effect of reducing of my JavaScript, so that I'm not misled into thinking my code is optimal when it's not, or confused that the JavaScript size remains the same.
Solution
The "Importing a modular component" provides two example syntaxes, but only one of them has the intended effect of reducing the size of the JavaScript bundle. The changes here remove the other example code.
Testing and review
Testing with ESBuild bundler:
Before: 73.8kb
After: 5.0kb
Diff: -68.8kb (-93.2%)