-
Notifications
You must be signed in to change notification settings - Fork 57
Bug Fix Particle Banner DOM enhancement #1389
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Replace DOM particle simulation with canvas and pause when idle/offscreen Why The banner’s DOM-based particle simulation was CPU-intensive due to many per-frame DOM mutations running continuously even when not interacting or visible. What changed Switched to canvas renderer: Added src/components/ui/CanvasParticles.tsx to draw all particles in one <canvas>, removing per-particle DOM nodes and style recalculations. Paused when idle/offscreen: In src/components/ui/InteractiveBanner.tsx, particles only render when the banner is hovered, in viewport (IntersectionObserver), and tab is visible (Page Visibility API). Throttled frame rate: Simulation capped at ~30fps. Reduced work per frame: Fewer particles, softer physics, and trails disabled when idle. Brand-aligned color: Particles now render using theme --primary via hsl(var(--primary)). Cleanup: Removed src/components/ui/PhysicsParticles.tsx and its import. Files Updated: src/components/ui/InteractiveBanner.tsx Added: src/components/ui/CanvasParticles.tsx Removed: src/components/ui/PhysicsParticles.tsx Impact Significant CPU reduction on idle pages and when the banner is offscreen. Fewer layout/paint invalidations; smoother interactions. Visuals preserved with primary brand color and subtle glow.
✅ Deploy Preview for snowplow-docs ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
- lowered the frame rate even further - reduced FPS from 30 to 20 - hard cap per frame drawing time
@miike reduced some of the rendering values even more. Let me know if this helps. |
It's down to about 15% now (it is still re-rendering the DOM without interaction to compute a gradient) ideally we'd want it somewhere below 1% (you can check in Chrome what the performance looks like compared to your other tabs). |
@miike, I have removed the canvas particle from the ui. I will think of another way of adding interactivity without so much rendering power. |
Replace DOM particle simulation with canvas and pause when idle/offscreen
Why
What changed
Switched to canvas renderer: Added src/components/ui/CanvasParticles.tsx to draw all particles in one , removing per-particle DOM nodes and style recalculations.
Paused when idle/offscreen: In src/components/ui/InteractiveBanner.tsx, particles only render when the banner is hovered, in viewport (IntersectionObserver), and tab is visible (Page Visibility API).
Throttled frame rate: Simulation capped at ~30fps.
Reduced work per frame: Fewer particles, softer physics, and trails disabled when idle.
Brand-aligned color: Particles now render using theme --primary via hsl(var(--primary)).
Cleanup: Removed src/components/ui/PhysicsParticles.tsx and its import.
Files
Updated: src/components/ui/InteractiveBanner.tsx
Added: src/components/ui/CanvasParticles.tsx
Removed: src/components/ui/PhysicsParticles.tsx
Impact
Significant CPU reduction on idle pages and when the banner is offscreen.
Fewer layout/paint invalidations; smoother interactions.
Visuals preserved with primary brand color and subtle glow.