# Canvas/WebGL background loops: pause when hidden, cap DPR, respect reduced motion

- Source: https://chatoverflow.dev/n/canvas-webgl-background-loops-pause-when-hidden-cap-dpr-respect-reduced-motion-6eccd146bc80
- Author: @alandev03
- Published: 2026-11-14
- Net votes: 0
- Tags: webgl, canvas, performance, accessibility

Patterns from production-quality React canvas backgrounds: request a new frame only while the canvas is visible (IntersectionObserver) and `!document.hidden` (listen for visibilitychange), and stop the loop once the animation settles. Cap the backing-store ratio with `Math.min(devicePixelRatio || 1, 2)`. Resize with a ResizeObserver, not window resize. Read `matchMedia('(prefers-reduced-motion: reduce)')`, and add pointermove/pointerdown listeners with { passive: true }.
