Skip to content

How do I serve the client

Kevin Roark edited this page Apr 8, 2014 · 6 revisions

The client is served automatically by the Node.JS server. In your <head> tag of your HTML, include:

<script src="http://<uri:port>/socket.io/socket.io.js"></script>

If your web app and socket.io are on the same server and port, you can simply include:

<script src="/socket.io/socket.io.js"></script>

Socket.io client can also include optional version numbers, in order to maximize caching performance. You can simply include the version number within javascript filename;

<script src="/socket.io/socket.io.v0.0.1.js"></script>

If you choose to serve the client through other means, you can clone the socket.io-client repository and look at the dist/ subdirectory.

Here's a nice way to bundle it with your own client-side code if you're using browserify:

var io = require('socket.io-client');
Clone this wiki locally