javascript-best-practices
Modern JavaScript best practices and performance optimization guidelines. Use when writing, reviewing, or refactoring JavaScript code to ensure optimal performance, maintainability, and modern patterns.
- License 许可
- MIT
- 最近更新
- 2026-08-24
- Stars
- ★ 2
- Forks
- 0
01 前言 Front Matter
- name
- javascript-best-practices
- license
- MIT
- metadata
- { "author": "your-name", "version": "1.0.0" }
- description
- Modern JavaScript best practices and performance optimization guidelines. Use when writing, reviewing, or refactoring JavaScript code to ensure optimal performance, maintainability, and modern patterns.
02 资源文件 11
- 参考文档description_ar.txt321 B
- 参考文档description_cn.txt166 B
- 参考文档description_de.txt230 B
- 参考文档description_en.txt203 B
- 参考文档description_es.txt223 B
- 参考文档description_fr.txt268 B
- 参考文档description_it.txt246 B
- 参考文档description_ja.txt308 B
- 参考文档description_ko.txt224 B
- 参考文档description_ru.txt457 B
- 参考文档description_tw.txt166 B
03 SKILL.md 正文
JavaScript Best Practices
Comprehensive guide for modern JavaScript development covering performance, code quality, and best practices.
When to Apply
Reference these guidelines when:
- Writing new JavaScript code
- Reviewing code for performance or quality issues
- Refactoring existing JavaScript code
- Optimizing application performance
- Ensuring code maintainability
Rule Categories by Priority
| Priority | Category | Impact | Prefix |
|---|---|---|---|
| 1 | Performance | CRITICAL | perf- |
| 2 | Async Patterns | HIGH | async- |
| 3 | Error Handling | HIGH | error- |
| 4 | Code Quality | HIGH | quality- |
| 5 | Modern Syntax | MEDIUM | modern- |
| 6 | Arrays | MEDIUM | array- |
Quick Reference
1. Performance (CRITICAL)
perf-avoid-memory-leaks- Always cleanup event listeners, timers, intervals, subscriptions, and observers
2. Async Patterns (HIGH)
async-promise-chains- Prefer async/await over .then()/.catch() chains for better readability
3. Error Handling (HIGH)
error-defensive-programming- Use guard clauses and validate input at system boundarieserror-explicit-validation- Don't hide data errors with optional chaining - validate explicitly
4. Code Quality (HIGH)
quality-strict-equality- Use === instead of == (except for null checks)quality-explicit-boolean-checks- Don't rely on truthy/falsy for non-boolean valuesquality-small-functions- Keep functions focused on one task (5-15 lines ideal)quality-no-magic-numbers- Extract numbers to named constantsquality-immutability- Prefer creating new objects/arrays over mutating existing onesquality-pure-functions- Write functions with no side effects when possiblequality-naming-conventions- Use meaningful, consistent names (camelCase, PascalCase, UPPER_SNAKE_CASE)quality-commenting- Comments explain "why", not "what" - code should be self-documentingquality-avoid-console-log- Use structured logging with levels in production
5. Modern Syntax (MEDIUM)
modern-const-let-no-var- Never use var; prefer const, use let only when reassignment is needed
6. Arrays (MEDIUM)
array-mutation-safety- Avoid in-place mutations (push, sort, reverse) on shared arrays
How to Use
Read individual rule files for detailed explanations and code examples:
rules/perf-avoid-memory-leaks.md
rules/async-promise-chains.md
rules/error-defensive-programming.md
rules/quality-strict-equality.md
Each rule file contains:
- Brief explanation of why it matters
- Incorrect code example with explanation
- Correct code example with explanation
- Additional context and references
Full Compiled Document
For the complete guide with all rules expanded: AGENTS.md
04 同仓库更多 Skills
three-best-practices
Three.js performance optimization and best practices guidelines. Use when writing, reviewing, or optimizing Three.js code. Triggers on tasks involving 3D scenes, WebGL/WebGPU rendering, geometries, materials, textures, lighting, shaders, or TSL.
css-best-practices
Guidelines for building modern, performant, and accessible CSS using MDN best practices. Use this when styling components, fixing layout shifts, or optimizing CSS performance.
frontend-dev
Full-stack frontend development combining premium UI design, cinematic animations, AI-generated media assets, persuasive copywriting, and visual art. Builds complete, visually striking web pages with real media, advanced motion, and compelling copy. Use when: building landing pages, marketing sites, product pages, dashboards, generating media assets (image/video/audio/music), writing conversion copy, creating generative art, or implementing cinematic scroll animations.
exa-rate-limits
Implement Exa rate limiting, backoff, and idempotency patterns. Use when handling rate limit errors, implementing retry logic, or optimizing API request throughput for Exa. Trigger with phrases like "exa rate limit", "exa throttling", "exa 429", "exa retry", "exa backoff".
exa-deploy-integration
Deploy Exa integrations to Vercel, Fly.io, and Cloud Run platforms. Use when deploying Exa-powered applications to production, configuring platform-specific secrets, or setting up deployment pipelines. Trigger with phrases like "deploy exa", "exa Vercel", "exa production deploy", "exa Cloud Run", "exa Fly.io".
exa-core-workflow-a
Execute Exa primary workflow: Core Workflow A. Use when implementing primary use case, building main features, or core integration tasks. Trigger with phrases like "exa main workflow", "primary task with exa".