Cettia JavaScript Client A is a lightweight B JavaScript client for browser-based C and Node-based D application.

Cettia 1.0.0-Beta1 client.
12.81KB minified, 4.6KB minified and gzipped.
It has no dependency and follows jQuery 2.x's browser support that embraces Internet Explorer 9.
Though browser is the first runtime, it runs seamlessly on Node.js.

Quick Start

Cettia JavaScript Client is distributed at two places according to runtime engine: browser version through this web site in compressed and uncompressed forms and node version through npm.


<script src="/cettia/cettia.min.js"></script>


var cettia = require("cettia-client");

Once you’ve loaded the module, you will be able to write the following echo and chat client. This page already loaded the uncompressed version, hence, you can run and debug it directly by copying and pasting to JavaScript console if possible.

var socket = cettia.open("http://localhost:8080/cettia");

// Lifecycle events
// When the server issues a new id for this socket as the beginning of the lifecycle and the end of the previous lifecycle
socket.on("new", function() {
    console.log("on new");
// When the selected transport starts connecting to the server
socket.on("connecting", function() {
    console.log("on connecting");
// When the connection is established successfully
socket.on("open", function() {
    console.log("on open");
// When an error happens on the socket
socket.on("error", function(error) {
    console.error("on error", error);
// When the connection is closed, regarded as closed or could not be opened
socket.on("close", function() {
    console.log("on close");
// When a reconnection is scheduled
socket.on("waiting", function(delay, attempts) {
    console.log("on waiting", attempts, delay);

// echo and chat events
socket.on("open", function() {
  // Text data
  socket.send("echo", "echo");
  socket.send("chat", "chat");
  // Binary data
  // From Encoding standard https://encoding.spec.whatwg.org/
  var encoder = new TextEncoder();
  socket.send("echo", encoder.encode("echo"));
  socket.send("chat", encoder.encode("chat"));
  // Composite data
  socket.send("echo", {text: "echo", binary: encoder.encode("echo")});
  socket.send("chat", {text: "chat", binary: encoder.encode("chat")});
  // In Node.js, use Buffer, i.e. new Buffer("echo"), to deal with binary data
socket.on("echo", function(data) {
    console.log("on echo", data);
socket.on("chat", function(data) {
    console.log("on chat", data);


Here is working example – echo and chat