How I built an open-source JavaScript performance analyzer with AST parsing, budget validation, and CI/CD integration.
Every JavaScript project eventually faces performance issues. Bundle sizes grow, complexity increases, and suddenly your app takes 5 seconds to load. I wanted a tool that could:
Perf-Wizard is an enterprise-grade performance analysis tool I built and open-sourced. It combines static analysis with practical optimizations.
Instead of guessing about performance issues, Perf-Wizard parses your code into an Abstract Syntax Tree:
const { BudgetValidator } = require('perf-wizard');
const validator = new BudgetValidator({
score: { min: 80, failCi: true }
});
Different frameworks need different optimizations:
useMemo/useCallback, prop drilling, unnecessary re-rendersSet thresholds and fail builds when code quality drops:
# GitHub Actions
- run: npx perf-wizard --ci --score-threshold 80
Every file gets a grade from A+ to F:
| Grade | Score | Meaning | |-------|-------|---------| | A+ | 90-100 | Excellent | | A | 80-89 | Good | | B | 70-79 | Fair | | C | 60-69 | Needs work | | F | 0-49 | Critical |
TypeScript files need special handling. I used Babel with the TypeScript preset:
const parser = require('@babel/parser');
const ast = parser.parse(code, {
sourceType: 'module',
plugins: ['typescript', 'jsx']
});
Re-analyzing unchanged files is wasteful. I implemented a hash-based caching system:
Developers want real-time feedback. The watch mode required:
chokidarTry it yourself: npm install -g perf-wizard
Repository: github.com/Airyshtoteles/perf-wizard