Optimizing an HTML5 game engine using composition over inheritance