---
title: "Comment by Vic Moreno on \"How I Built Haze: Live WebGL Backgrounds While Learning Shaders\" | Hashnode"
description: "One script tag for animated WebGL backgrounds is a nice constraint. How much does it cost on the main thread on a mid-range phone?"
url: "https://hashnode.com/posts/how-i-built-haze-live-webgl-backgrounds/6afca0be9211f92892dd65d2/comment/6afd68bf23945f21dcd0037e"
---

[Discussion](https://hashnode.com/posts/how-i-built-haze-live-webgl-backgrounds/6afca0be9211f92892dd65d2)

Comment [How I Built Haze: Live WebGL Backgrounds While Learning Shaders](https://hashnode.com/posts/how-i-built-haze-live-webgl-backgrounds/6afca0be9211f92892dd65d2)

[Vic Moreno](https://hashnode.com/@itsvicmoreno)

[Nov 18](https://hashnode.com/posts/how-i-built-haze-live-webgl-backgrounds/6afca0be9211f92892dd65d2/comment/6afd68bf23945f21dcd0037e)

One script tag for animated WebGL backgrounds is a nice constraint. How much does it cost on the main thread on a mid-range phone?

[Israel Oyetunji](https://hashnode.com/@IsraelMitolu)

[Nov 20](https://hashnode.com/posts/how-i-built-haze-live-webgl-backgrounds/6afca0be9211f92892dd65d2/comment/6afd68bf23945f21dcd0037e#reply-6b001bce574763324cb5e73a)

Great question. The main thread does very little actually. Each frame it just updates a couple of values and asks the GPU to draw, and the GPU does all the heavy lifting. On my desktop, the heaviest design uses about a third of the frame budget even at full 4K.

I also had my brother test it on his mid-range phone, and it was pretty smooth. It caps the pixel ratio there too, so phones don't draw more pixels than they need to 🙂

[Vic Moreno](https://hashnode.com/@itsvicmoreno)

[Nov 20](https://hashnode.com/posts/how-i-built-haze-live-webgl-backgrounds/6afca0be9211f92892dd65d2/comment/6afd68bf23945f21dcd0037e#reply-6b002e0f8ec420b77d558a34)

A third of the frame budget at 4K leaves a good margin, and the pixel ratio cap is the right lever on phones. Two cheap wins if they are not in yet: stop the loop when the canvas scrolls out of view (IntersectionObserver), and serve a still frame under prefers-reduced-motion. Does Haze already handle either?
