Hi
I’m relatively new to JS and am attempting to create a simple vanilla JS library that adds a snowfall feature on a website. I’m kind of unsure how i would even go about starting it so was wondering if anyone could help offer some tips to get me started.
Right now where my brain is at: I feel the math.random
function is gonna be very helpful and rather than using an image or css to create the snowflakes I was thinking just use an icon like '❄'
. Then i guess i’ll need a max snowflakes on screen at a time + once falls out of users screen remove the element.
What i’m unsure about is how do i create the snowfall. A for loop? Do i spam the dom and inject 50 snowflakes etc.?
What would you suggest is a clean way to approach this and also in a way that wouldn’t cause lag? Thanks so much.