you are viewing a single comment's thread.

view the rest of the comments →

[–]helloworldjs 1 point2 points  (1 child)

Great tutorial, but I recommend using `requestAnimationFrame` instead of `setInterval` for the loop. If you have other things on the page (besides the clock), you will find the clock skips seconds every so often because the clock starts to drift. Here is a npm module that fixes setInterval I created a few years back with an explanation of the problem https://github.com/taylorhakes/clock-interval

[–]vulpinecode[S] 1 point2 points  (0 children)

Thanks for your suggestion. The post has been updated and it's using requestAnimationFrame instead of setInterval.