Hi, there are a couple of things you could do to improve performance of this script:
- Don't store state as a class on the body. Hitting the DOM is expensive. Just store it in a variable, unless of course you want to expose each state to CSS.
- Cache your jQuery selectors outside of the
setInterval and for loops.
<3