<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <title>Twitter Application</title>
    <!-- Latest compiled and minified CSS -->
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">

    <!-- Optional theme -->
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap-theme.min.css">

    <!-- Latest compiled and minified JavaScript -->
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
  </head>
  <body>

    <ul id="messages"></ul>
      <form action="">
        <input id="m" autocomplete="off" /><button>Send</button>
      </form>


      <script src="https://cdn.socket.io/socket.io-1.2.0.js"></script>
      <script src="http://code.jquery.com/jquery-1.11.1.js"></script>
      <script>
      var socket = io('http://localhost:8000');

        socket.on('connect', function() {
            console.log('Successful connection to the server.');
        });

        $('form').submit(function(){
          var message = $('#m').val();
          socket.emit('add', {word:message});
          $('#m').val('');
          return false;
        });

        socket.on('add', function(msg){
          $('#messages').append($('<li>').text(msg));
        });
      </script>
  </body>
</html>

<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <title>Twitter Application</title>
    <!-- Latest compiled and minified CSS -->
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">

    <!-- Optional theme -->
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap-theme.min.css">

    <!-- Latest compiled and minified JavaScript -->
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
  </head>
  <body>

    <ul id="messages"></ul>
      <form action="">
        <input id="m" autocomplete="off" /><button>Send</button>
      </form>


      <script src="https://cdn.socket.io/socket.io-1.2.0.js"></script>
      <script src="http://code.jquery.com/jquery-1.11.1.js"></script>
      <script>
      var socket = io('http://localhost:8000');

        socket.on('connect', function() {
            console.log('Successful connection to the server.');
        });

        $('form').submit(function(){
          var message = $('#m').val();
          socket.emit('add', {word:message});
          $('#m').val('');
          $('#messages').append($('<li>').text(message));

          return false;
        });

        socket.on('add', function(msg){
          $('#messages').append($('<li>').text(msg));
        });
      </script>
  </body>
</html>

Move topic append func to 'add' callback
Move topic append func to 'add' callback
