Long story short, I’m trying to create an animated background consisting of slowly falling transparent rectangles. I’ve found a script that allowed me to get pretty close with each shape being randomized in both initial starting position and its dimensions but it’s not entirely there because I think it can be a little more efficient. The animation is a tiny bit “stutterish” and it also seems to be a CPU / RAM hog as it makes other tabs in my browser lazy at reacting.
Here’s the overall script I’m toying with right now (uses jQuery 2.1.3) to give you an idea of what I’m shooting for:
Just put an image of a square into the same folder that this HTML file will go in and name it “bg.png.” Then load it up in a browser and you’ll see the effect I’m shooting for.
What ways exist to get the same result only in a “lighter” (less heavy) way? To start with, I think the setInterval() is responsible for the animation stutter. Are there better ways to make the animation happen? I’m currently looking into using requestAnimationFrame() but I’ve never used this before. I’d also like to avoid using canvas if possible.
Thank in advance.