Though outside the scope of this book, you should consider using Web Workers if performance is critical to you. Doing so will ensure that a particular update loop always fires at a consistent rate.
Web Workers is an API that allows web applications to spawn background processes that run scripts in parallel to their main page. This allows for thread-like operation with message-passing as the coordination mechanism.