1

I understand that the socket.io JavaScript client file will be served from the Node.js server, but this is not good because I've used some sort of JavaScript library dependency manager like require.js or steal.js.

I wish I could serve the socket.io client JavaScript file from my main (static assets) server, not from Node.js server. Is this doable? And how can I achieve this?

Dan Dascalescu
  • 143,271
  • 52
  • 317
  • 404
user469652
  • 48,855
  • 59
  • 128
  • 165

3 Answers3

0

Socket.io is already useable from a client, and although on the server-side it's usually used with node.js, there is no reason you can't use it from another Javascript library. It has no node.js dependencies I'm aware of.

Yusuf X
  • 14,513
  • 5
  • 35
  • 47
  • I can use it, but I need to get the source and build with other packages. And I'm not sure how to do it to make it right because of the awful files. – user469652 May 11 '12 at 17:22
0

According to the documentation is how you server socket.io to client. As far as I know you cannot serve socket.io like node does to the client from outside node server. Please do correct me if i'm wrong

Hope this helps

Dhiraj
  • 33,140
  • 10
  • 61
  • 78
  • However, the documentation @DhirajBodicherla refers to also states: »If you choose to serve the client through other means, you can clone the socket.io-client repository and look at the dist/ subdirectory.» So it is possible, but requires some extra effort. – Ville Dec 18 '12 at 21:54
  • The Socket.io client library is also included with the Node.js package, as mentioned at [Where is the socket.io client library?](http://stackoverflow.com/questions/8528681/where-is-the-socket-io-client-library). Or, you can clone it from [GitHub](https://github.com/LearnBoost/socket.io-client). – Ville Dec 18 '12 at 22:04
0

The easiest way is to include the socket.io client JavaScript library from CDNJS:

<script src="//cdnjs.cloudflare.com/ajax/libs/socket.io/0.9.10/socket.io.min.js"><script>
Dan Dascalescu
  • 143,271
  • 52
  • 317
  • 404