thedaviddias/Front-End-Checklist / skills/js-libraries
js-libraries
VerifiedUse when auditing slow page loads, heavy assets, or rendering delays related to Use secure and up-to-date JS libraries. Verify the actual bottleneck in DevTools, Lighthouse, or field data before recommending changes.
| File | Kind | Size |
|---|---|---|
| SKILL.md | skill md | 1.7 KB |
| references/rule.md | markdown | 2.6 KB |
references/rule.md
View on GitHub# Use secure and up-to-date JS libraries
> Detects JavaScript libraries and checks for known vulnerabilities
**Priority:** medium · **Difficulty:** intermediate · **Time:** 10 min
---
JavaScript libraries can quickly accumulate and introduce security risks or performance bottlenecks if not managed carefully.
## Code Examples
#
## Checking for Vulnerabilities
```bash
# Using npm
npm audit
# Using pnpm
pnpm audit
# Using yarn
yarn audit
```
### Replacing Heavy Libraries
```javascript
// ❌ Bad: Importing a heavy library like Moment.js (280KB+)
console.log(moment().format('MMMM Do YYYY'));
// ✅ Good: Using a lightweight alternative like date-fns (modular imports)
console.log(format(new Date(), 'MMMM do yyyy'));
```
## Why It Matters
- **Security**: Outdated libraries are a primary vector for cross-site scripting (XSS) and other attacks.
- **Performance**: Many older libraries were designed for a different era and include redundant polyfills or non-tree-shakable code.
- **Maintenance**: Keeping dependencies up-to-date simplifies future upgrades and ensures access to the latest features and bug fixes.
- **Bundle Size**: Libraries often make up the bulk of a web application's JavaScript; optimizing them has a high impact.
## Best Practices
Run [npm audit](https://docs.npmjs.com/cli/v10/commands/npm-audit) or an equivalent scan before replacing libraries, because the biggest wins usually come from removing one outdated or oversized dependency rather than blindly rotating packages.
✅ **Regular Audits**: Run `npm audit` or use tools like Snyk as part of your CI/CD pipeline.
✅ **Modular Imports**: Choose libraries that support ES Modules and tree-shaking.
✅ **Check BundlePhobia**: Before adding a new library, check its impact on bundle size.
✅ **Native Alternatives**: Use native browser APIs (e.g., `Intl` for formatting, `fetch` for requests) instead of libraries when possible.
## Tools & Validation
- [npm-audit](https://docs.npmjs.com/cli/v7/commands/npm-audit)
- [Snyk](https://snyk.io/)
- [BundlePhobia](https://bundlephobia.com/)
- [Dependabot](https://github.com/dependabot)
## Verification
### Automated Checks
- Measure the affected page or flow in Lighthouse, PageSpeed Insights, or DevTools and confirm the targeted metric improves.
- Inspect the network waterfall or performance timeline to confirm the intended resource or execution change actually took effect.
### Manual Checks
- Verify the change on a throttled mobile profile, not just local desktop.
- If this rule maps to a budget or Web Vital, confirm the page now stays within that threshold.Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| rea-analysis-optimizationmorluto/reaOptimize REA providers and shared analysis workflows for agent context, latency, CPU, and memory while preserving correctness and Evidence. Use for analysis bottlenecks and cache or query design; CI/test-suite optimization belongs to rea-ci-tests-audit. | Stars: 471k | Updated | Claude CodeCodex | Verified | Install |
| rea-ci-tests-auditmorluto/reaAudit REA CI and test suites for correctness, fixture drift, false passes, and measured performance; use for suite or workflow investigations and efficiency changes, rather than ordinary feature testing or a single test failure. | Stars: 471k | Updated | Claude CodeCodex | Verified | Install |
| rea-tool-designmorluto/reaAudit, investigate, design, or change REA investigation tools, CLI/MCP contracts, provider capabilities, and Evidence semantics. | Stars: 471k | Updated | Claude CodeCodex | Verified | Install |
| ponytail-auditDietrichGebert/ponytailQuality audit of the whole repo: bugs, security, real load, missing tests, speed, and what to delete. Most important first. | Stars: 194k | Updated | Claude CodeCodex | Verified | Install |