One thousand components
Build high-performance applications that efficiently render and animate thousands of components using Aurelia's optimized rendering pipeline.
Learn how to build high-performance Aurelia applications that can smoothly render and animate thousands of components simultaneously. This tutorial demonstrates rendering techniques, performance optimization, and best practices for extreme-scale UIs using an animated visualization with 10,000+ SVG elements.
Why This Is an Advanced Scenario
Rendering thousands of components challenges:
Rendering performance - Minimizing DOM updates
Memory efficiency - Managing thousands of objects
Animation smoothness - 60 FPS with heavy workloads
Data structures - Efficient updates and mutations
Change detection - Smart dirty checking strategies
Browser limits - Working within DOM constraints
This tutorial demonstrates:
Efficient
repeat.forusage at scaleRAF (Request Animation Frame) scheduling
Batch DOM updates
Object pooling and reuse
SVG performance optimization
Profiling and debugging techniques
The Demo
We'll build an interactive visualization that:
Renders 10-10,000 animated SVG rectangles
Transitions between 4 different layout patterns (Grid, Wave, Spiral, Phyllotaxis)
Maintains 60 FPS throughout
Uses interpolated colors for visual appeal
Provides interactive controls for component count
Live example: Based on the InfernoJS 1k Components benchmark.
Project Setup
Part 1: Layout Algorithms
First, create the mathematical layout strategies:
Key Insights:
Phyllotaxis: Golden angle spiral (sunflower seed pattern)
Grid: Simple square grid layout
Wave: Sinusoidal wave pattern
Spiral: Logarithmic spiral
Part 2: Point Data Model
Create the data model that each rendered element uses:
Performance Techniques:
Pre-compute all layouts - Every point knows all 4 positions
Interpolation - Smooth transitions between layouts
Static properties - Share animation state across all points
Integer truncation -
~~valuefaster thanMath.floor()
Part 3: Main Application Component
Performance Techniques:
Persistent RAF - Single animation loop for all points
Batch updates - Update all points together
Smart array manipulation - Reuse existing points when possible
Splice optimization - Remove from end (faster than shift)
Part 4: Template
Template Optimizations:
SVG over HTML - Faster rendering for graphics
Minimal bindings - Only
transformandfillDebounced input - Prevent excessive updates
Single container - One
<g>for all rectangles
Part 5: Styling
CSS Performance:
will-change: transform- GPU acceleration hinttransformoverleft/top- Composite-only changesMinimal reflows - Absolute positioning
No transitions - JavaScript handles animation
Performance Analysis
Profiling Results
100
60
~5MB
101
1,000
60
~15MB
1,001
5,000
58-60
~45MB
5,001
10,000
50-55
~80MB
10,001
Bottlenecks
Layout calculations - O(n) per frame
String concatenation -
transformattributeColor interpolation - Viridis lookup
DOM updates - Bindings update detection
Optimization Strategies
1. Object Pooling
2. Virtualization
3. Web Workers
4. Canvas Rendering
Browser DevTools Profiling
Performance Tab
Record during animation
Look for:
Frame rate drops (<60 FPS)
Long tasks (>16ms)
Excessive garbage collection
Layout thrashing
Memory Tab
Take heap snapshot
Check:
Retained size of Point instances
Detached DOM nodes
String allocations (transform)
Rendering Tab
Enable:
Paint flashing - See repaint regions
Layout shift regions - Detect reflows
Layer borders - Check compositing
Common Pitfalls
1. String Allocation Churn
❌ Bad:
✅ Good:
2. Unnecessary Re-renders
❌ Bad:
✅ Good:
3. Memory Leaks
❌ Bad:
✅ Good:
Real-World Applications
Data Visualization
Scatter plots with 10k+ data points
Network graphs with thousands of nodes
Real-time sensor data displays
Gaming
Particle systems
Sprite-based animations
Tilemap renderers
Enterprise
Large data tables with virtual scrolling
Real-time dashboards
Log viewers with thousands of entries
Key Takeaways
Pre-compute when possible - Don't calculate in getter
Batch updates - Use
batchProfile religiously - Measure, don't guess
Consider alternatives - Canvas for 50k+ elements
Smart data structures - Object pools, efficient arrays
GPU acceleration - Use
transformandwill-change
Resources
Next Steps
Add Web Worker support for calculations
Implement Canvas fallback for 50k+ points
Add more layout algorithms
Benchmark against other frameworks
Profile memory usage patterns
Implement object pooling
Last updated
Was this helpful?