Skip to content

[Optimization] Optimize DOM in tempo.js#4606

Closed
AnvitaPrasad wants to merge 1 commit intosugarlabs:masterfrom
AnvitaPrasad:optimise-don-tempo
Closed

[Optimization] Optimize DOM in tempo.js#4606
AnvitaPrasad wants to merge 1 commit intosugarlabs:masterfrom
AnvitaPrasad:optimise-don-tempo

Conversation

@AnvitaPrasad
Copy link
Contributor

Issue: #4461

DOM Optimization in tempo.js widget

Optimized the tempo.js widget to improve performance by:

  1. Caching canvas contexts during initialization instead of getting them repeatedly in the draw loop
  2. Creating a style template object for efficient application to multiple canvases
  3. Caching frequently accessed properties (blockList, logo) to reduce property lookups
  4. Simplifying conditional logic using ternary operators for cleaner, faster code
  5. Reusing current time values instead of creating multiple Date objects
  6. Extracting canvas click handler to a separate method for better organization

These changes maintain identical functionality while improving rendering efficiency, especially during animation loops that run at 5ms intervals.

@github-actions
Copy link
Contributor

github-actions bot commented Apr 6, 2025

✅ All Jest tests passed! This PR is ready to merge.

@AnvitaPrasad
Copy link
Contributor Author

@walterbender pls review . thanks

@github-actions
Copy link
Contributor

github-actions bot commented Jun 5, 2025

This pull request has been open for more than 60 days without any activity. It will be closed in 3 days unless the stale label is removed or commented on.

@github-actions github-actions bot added the Stale label Jun 5, 2025
@github-actions
Copy link
Contributor

github-actions bot commented Jun 8, 2025

Closed pull request due to inactivity for more than 63 days.

@github-actions github-actions bot closed this Jun 8, 2025

// How much time has gone by?
deltaTime = this._widgetNextTimes[i] - d.getTime();
deltaTime = this._widgetNextTimes[i] - currentTime;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs to be a separate call to getTime()

@walterbender
Copy link
Member

How did you test this? To me, the changes to getTime don't look correct.

@walterbender walterbender reopened this Jun 24, 2025
@github-actions
Copy link
Contributor

Closed pull request due to inactivity for more than 63 days.

@github-actions github-actions bot closed this Jun 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants