DEV Community

Discussion on: Simple Analog Clock Using Html, CSS & Javascript

Collapse
 
jfftck profile image
jfftck

I have some suggestions on how to improve this.

  1. Create a function that handles the redraw interval using window.requestAnimationFrame() and window.setTimeout() instead of window.setInterval() as it should cut down on rendering cycles.
  2. Look at using HTML canvas as it will use much less memory since only 1 HTML element is created.

These are the ways that I would expand on this code to improve, not only performance, but my skill set.

Collapse
 
maixuanhan profile image
Han Mai

I doubt that.

  1. How will requestAnimationFrame() help in this case? Interval resolution is 1 second.
  2. Are there any measurements for this or you’ve just guessed?

Some comments have been hidden by the post's author - find out more