Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reduce Paints and Cache DOM Queries #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

jackrugile
Copy link

Hey Jake,

I'm loving this project! So proud of you for quitting smoking and I think this type of visualization as a motivator is a great idea.

I'm submitting this pull request as part of #Hacktoberfest. I noticed that there were paints happening on all progresses each frame, even if the data hadn't changed. I reconfigured a few things to reduce that:

  • Reduce paints (only repaints if the value has changed)
  • Store relevant values in const outside of RAF
  • Store references to queried DOM elements
  • Switch to Date.now() over new Date().getTime(), (slightly more performant)

You can see the before and after of the paint rectangles here: https://imgur.com/a/CAgp00c

No pressure to merge, of course. Best of luck to you on your journey!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant