var animate;
var Game = Game || {};
var WIDTH = window.innerWidth;
var HEIGHT = window.innerHeight;
var FPS = 1000 / 30;
var engine = new Game.Engine('game', WIDTH, HEIGHT);

engine.init();
engine.register(new Game.Snake(WIDTH, HEIGHT, {}));

// Use fallbacks for requestAnimationFrame
animate = (window.requestAnimationFrame ||
  window.webkitRequestAnimationFrame ||
  window.mozRequestAnimationFrame ||
  function(callback) {
    window.setTimeout(callback, FPS);
  });

// Taken from Mozilla
(function() {
  'use strict';
  function main() {
    Game.stopLoop = animate(main);
    engine.step();
  }
  main();
})();

var animate;
var Game = Game || {};
var WIDTH = window.innerWidth;
var HEIGHT = window.innerHeight;
var FPS = 1000 / 20;
var engine = new Game.Engine('game', WIDTH, HEIGHT);

engine.init();
engine.register(new Game.Snake(WIDTH, HEIGHT, {}));

// Use fallbacks for requestAnimationFrame
animate = (
  /*window.requestAnimationFrame ||
  window.webkitRequestAnimationFrame ||
  window.mozRequestAnimationFrame ||*/
  function(callback) {
    window.setTimeout(callback, FPS);
  });

// Taken from Mozilla
(function() {
  'use strict';
  function main() {
    Game.stopLoop = animate(main);
    engine.step();
  }
  main();
})();

Set the frame rate to 20 fps
Set the frame rate to 20 fps

requestAnimationFrame is way too fast to have a playable game. So this solution just sets the frame rate directly with setTimeout
