Closed rgwood closed 1 year ago
All looks good to me! Will test/merge/update the version when I grab a chance the next few days! 🙏🙏🙏
Cool!
I did some quick manual testing, just opened up index.html and moved my cursor around.
Second inspection, logic seems great!
Hello and thank you for this very cool project!
I use the fairy dust cursor on my website, and I happened to notice that it was using up a non-negligible amount of CPU time even when the cursor was idle. Some quick experiments suggested that the
context.clearRect()
call inupdateParticles()
was the culprit.This PR adds short-circuiting behaviour to
updateParticles()
so that we do less work when there are no particles to update. On my laptop[^1] CPU usage when idle goes from ~7% to 3%.I applied the fix to every cursor where it looked like it might be relevant (because the number of particles can go to zero).
[^1]: Surface Pro 8, i7-1185G7 CPU, 120hz display, Windows 11, latest Edge. CPU usage measured using the Performance Monitor tab in dev tools, on my website with a slightly customized version of the fairy dust cursor. Not the most reproducible benchmark but hopefully it will do 😅