A VNC client in 1K of JavaScript (for the 2012 js1k.com competition)
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
docs
utils
README.md
favicon.ico
shim.html
vnc-full.html
vnc-full.js
vnc.html

README.md

noVNC-js1k: a VNC client in 1k of JavaScript

Usage

You will need a VNC server that supports WebSocket connections (e.g. recent libvncserver/x11vnc) or you will need websockify to bridge between the browser and your VNC server.

As an alternative, there is a simple VNC server that you can download and run like this:

wget https://github.com/downloads/kanaka/noVNC-js1k/heart-vnc-server.zip
unzip heart-vnc-server.zip
./heart-vnc-server

Then load the live version of noVNC-js1k. When prompted enter "ws://localhost:5900".

What led you to this insanity?

In Feb of 2010 I started the noVNC project which is a full featured open source HTML5 VNC client.

In Sept 2010 I heard about the 10K Apart contest to do something interesting in 10k of JavaScript. It was too late to submit an entry for the contest but I was inspired to see if I could put noVNC on a diet and reach the 10K size limit. Diet noVNC was the result. Diet noVNC weighs in at just under 10K (after minification using packer). At the time, the full version of noVNC was about 120K of Javascript.

After reducing noVNC by an order of magnitude (base 10), the obvious next question is, "How much smaller is possible?". Okay, that may not be such an obvious question, but in Feb 2012 I got wind that the JS1K competition was running again and I wondered if it was even feasible to create a browser based VNC client in just 1 kilobyte (technicaly 1 kibibyte) of Javascript.

As it turns out, it is possible:

noVNC-js1k is a working VNC client and is implemented with less the 1024 bytes of Javascript.

Caveats

  • noVNC-js1k (like Diet noVNC) is not intended to replace noVNC in any sense. The amount of data sent via the VNC protocol in just a few seconds can be orders of magnitude larger than the size of the full noVNC client so the code size is really a non-issue in practice.

  • noVNC-js1k (even in the unminimized form) is definitely not an example of good coding practices. In fact, it is a good showcase of bad Javascript coding practices.

  • Modern browsers create full-duplex, long-lived, low latency network connections via WebSockets, but WebSocket connections are not raw network connections. To use noVNC-js1k you will either need a VNC server that support WebSocket connections directly (like recent versions of libvncserver/x11vnc) or you will need to use websockify to bridge between the browser and your VNC server.

  • noVNC-js1k does not support password authentication (yet another reason not to use it for anyting except learning and experimentation). If you use vncserver to start your VNC server, you may need to make a copy of the script and comment out the authType seting near the beginning of the script. If you are using x11vnc do not use any of the password options.

Features

noVNC-js1k has the following limited functionality:

  • Raw encoding
  • Mouse movement
  • Left mouse button clicks
  • Keyboard input (a few symbols are on the wrong keys)
  • Encryption (wss://) support
  • Works in Chrome and Firefox (any browser with native WebSocket support)

Missing features (compared to noVNC)

The following features of the full noVNC are missing.

  • User interface (WebSocket URI passed as fragment ID)
  • VNC authentication (server must have password disabled)
  • Other encodings (including no DesktopSize/resize)
  • Colour mapped support (true-color only)
  • Local cursor rendering
  • Clipboard support
  • Error messages / connection status
  • Performance optimizations