Search code examples
javascriptcsshtmlwindows-store-appsmicrosoft-metro

Terrible lag in HTML5/JavaScript game when animating


My HTML5/JavaScript game (for the windows store) is lagging constantly! I have used barely any resources and I have used gsap for animating the bullets and mines. For example: http://203.81.207.90/default.html in Chrome enabling everything under rendering shows the lag immediately (the background and mines lag the most).


Solution

  • the problem is the tiny interval (10ms) used in most setInterval()'s.
    increasing the interval should help and since javascript is a single threaded language, using lots of timers basically queue's them (performance issue) try using less timers by putting multiple functions in single timers