Bundle Size Reducer
Iteratively reduces JavaScript bundle size by analyzing dependencies, identifying large modules, and applying targeted optimizations until a specified size target is met.
Goal
Reduce bundle size to target threshold
How to Run
Run automated prompts in your coding environment to iteratively reduce bundle size using analysis and optimization steps.
- 01
Setup Environment
Ensure you have a bundle analyzer tool installed (e.g., webpack-bundle-analyzer) and can run build commands.
- 02
Run Initial Analysis
Execute the kickoff prompt to get current bundle size and analysis report.
- 03
Apply Optimization Prompts
For each iteration, run the generated prompts to identify and apply bundle optimizations.
- 04
Check Results
After each optimization, run the bundle analyzer to verify size reduction progress.
- 05
Iterate Until Target
Repeat steps 3-4 until the bundle size meets your target or max iterations reached.
Workflow Steps
- 01
Analyze current bundle composition using bundle analyzer
- 02
Identify top largest modules/dependencies contributing to bundle size
- 03
Research and select appropriate optimization strategies for identified modules
- 04
Apply optimizations via build configuration changes (code splitting, tree shaking, etc.)
- 05
Rebuild and reanalyze bundle to measure impact
- 06
Compare new bundle size against target threshold
If target met, exit loop; otherwise, return to step 1
Kickoff Prompt
Start the "Bundle Size Reducer" loop. Goal: Reduce bundle size to target threshold Max iterations: 10 Between iterations run: bundle analyzer Exit when: Size target achieved Please analyze the current JavaScript bundle size using your preferred analyzer tool (e.g., 'npx webpack-bundle-analyzer dist/static/js/*.js'). Report the total bundle size in KB/MB, identify the top 5 largest modules, and indicate whether the current size exceeds our target of [TARGET_SIZE]KB. Include the full analysis output in your response. Self-pace this loop. After each iteration, run `bundle analyzer` and evaluate the output, and only continue if the exit condition is not met (Size target achieved). Stop when the exit condition passes or 10 iterations are reached. Give a short status update each pass.
Guardrails
hardcoded- ·Do not modify source code files directly without prior analysis
- ·Always backup configuration files before making changes
- ·Test application functionality after each optimization
- ·Prioritize safe optimizations over aggressive ones
- ·Respect iteration limits to prevent infinite loops
Flow Diagram
Related loops — Performance
Performance
Frontend Speed Optimizer
Automatically improves frontend page speed by iteratively analyzing Lighthouse reports and applying targeted optimizations. This loop runs until your target Lighthouse performance score is achieved.
Performance
Slow Endpoint Hunter
This loop identifies and optimizes slow API endpoints by continuously benchmarking, analyzing performance bottlenecks, and applying targeted improvements until response times meet predefined budgets.
Performance
Database Latency Reducer
An automated loop designed to systematically identify and resolve database performance bottlenecks to reduce query response times. This agent analyzes execution plans, optimizes slow queries, and applies indexing strategies while maintaining data integrity and safety.