Chapter 5. Debugging and Optimization

One of the most rewarding parts about building HTML5 games for Windows 8 is the fact that, if your game is already running in the browser on the desktop, chances are good that it will run perfectly as a Windows Store app. Of course, in the real world, nothing works exactly like you expect it to. This chapter will go over some of the best ways to optimize your game so that it runs well on your computer and all the other Windows 8 devices out there.

Using the Console

If you are a fan of console.log(), you’ll be happy to know that all of your log traces will still show up in Visual Studio’s console window. This means the quickest way to debug your app is probably to throw a console.log() statement in there and see what’s happening. There are a few things that Visual Studio doesn’t support in the console output, which you may be used to in a browser log window:

  • Visual Studio will not output the structure of an object. This means you simply get a string equivalent of the object. For exploring objects, you will need to use the debugger and a breakpoint, which we will talk about next.

  • The console also doesn’t automatically add spaces to multiple items separated by a comma. So, if you do console.log(“show”, “me”, “this”) in the console, you will see “showmethis.” In WebKit browsers, the console would give you “show me this.” It’s not a deal breaker but something to keep in mind if you spend a lot of time trying to output multiple items in a single log statement. ...

Get Releasing HTML5 Games for Windows 8 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.