I know HTML5 is great for web games, but I don't really know if it's possible to develop online games with multiple users, keeping everybody synchronized and handling logins, et cetera. Is it possible to do this?


2 Answers 2


You can't write it with HTML5 alone. You will always need scripting and a server to handle communication between users, because of the security limits of browser scripting, and also to prevent cheating.

Many people have written multiplayer html5 games, even I have. The use of html5 itself is probably not the most important part of it. Most of the things needed (if not all) have been available in html 4.01 as well. The exception is canvas, but canvas is slower than svg, and svg was available in lots of browsers already.

I think what really spawned the "html5 game" mania is the ability to make server side apps in javascript. This means that all the client side programmers can suddenly make the entire system themselves, and they are usually the creative people when it comes to stuff like games. Not to mention that JS is so easy that even your grandma could program with it. Maybe.

Update after comment from OP:

A common architecture for a browser game would be

          Client                                     Server
|-----------------------|                   |---------------------|
View - input/output logic - Communication - Validation - Game World
              |                                              |
   client database (if needed)                    server database (if needed)

Or in terms of actual "languages":

  • Client view: HTML5 (possibly with angular.js, haven't tested how fast it is with LOTS going on yet. also check out raphael.js for "graphics")
  • Client logic: JavaScript (jquery/vapor/plain/whatever)
  • Client database: WebSQL (part of the HTML5 "suite" I suppose)
  • Communication: JSON (Javascript object notation, essentially serialized javascript objects) over socket.io (JS library for automatically detecting optimal communication protocols)
  • Server language: also JS (node.js if you have TONS of concurrent users on few cores, other solutions are available too)
  • Validation: just making sure your INCOMING game data (from client) is valid. Outgoing does not need to be checked, not even on client. It is assumed correct. Always.
  • Game World: a collection of VERIFIED data that is redistributed to all clients as they come in
  • Server database: couchdb, mongodb, whatever database that gives you raw json objects to work with.

There you are. A complete internet game written only using javascript and html. Lovely.

  • \$\begingroup\$ i find very interesting your answer, could you give me a little advice about which parts should i build (are most important) end to end and which technologies feed in each part, sorry about that, just trying to know how to build something an reliable. Thanks! \$\endgroup\$
    – arrrrgv
    Nov 9, 2011 at 1:25
  • 1
    \$\begingroup\$ +1, HTML5 is the rage, but what people attribute to it is mostly 4.01 functionality and JavaScript. Could I though ask you to not call JavaScript easy? It has got it's perks, but if you want to write real programs, you got to be a real programmer. JavaScript takes away the chores of variable declaration and memory management, but it does not make organizing your code and figuring algorithms and data structures any easier, and you definitely need a programmers mindset and experience for those tasks. \$\endgroup\$ Nov 9, 2011 at 9:09
  • \$\begingroup\$ @eBusiness what I mean by easy is that it's so condensed in terms of programming, and its use cases are documented to death. You can always find a tutorial or a function that does what you want. And it's easy to set up (you don't need to, it's already in the browser). \$\endgroup\$
    – Tor Valamo
    Nov 10, 2011 at 3:19
  • \$\begingroup\$ @arrrrgv updated post with answer to your question \$\endgroup\$
    – Tor Valamo
    Nov 10, 2011 at 3:37
  • 1
    \$\begingroup\$ +1 for a nice answer, although I doubt the rise of HTML5 games has anything to do with server-side JavaScript. Strictly speaking JS isn't even part of HTML5. I think it's the new features like canvas, webGL, audio and video and local storage that give HTML5 games a boost. And of course the fact that it's new and hyped so everybody jumps the bandwagon. \$\endgroup\$
    – bummzack
    Nov 10, 2011 at 7:11

Take a look at the article at http://smus.com/multiplayer-html5-games-with-node and also the source provided with the article. Note that this also uses JavaScript for networking.

  • 2
    \$\begingroup\$ Please write "JavaScript" as a single word, to avoid confusion. \$\endgroup\$
    – o0'.
    Nov 8, 2011 at 8:47
  • \$\begingroup\$ One day, Node.js won't be necessary -- when cross-browser support for web sockets is widespread. \$\endgroup\$
    – Engineer
    Nov 8, 2011 at 12:01
  • \$\begingroup\$ I don't see why cross-browser support for web sockets would change the need for a server component outside of any browser. You should always program a multiplayer game so that the clients connect to a central server, not directly client-to-client. \$\endgroup\$
    – jhocking
    Nov 8, 2011 at 13:00
  • 1
    \$\begingroup\$ Also check out NowJS (nowjs.com) \$\endgroup\$
    – Tim Holt
    Nov 8, 2011 at 18:20
  • \$\begingroup\$ web sockets are inherently unsafe for any application, which is the reason why the planned implementation was abandoned by so many browsers. you can't allow an environment which gets access to "anywhere" and at the same time can take input from "anywhere". \$\endgroup\$
    – Tor Valamo
    Nov 8, 2011 at 21:45

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .