I’m using socket.io. It works well, but I have a short doubt about the performance. I’m not sure that I use well the connection.
Here my client script (jade template language):
!!! 5
html
head
title Foo
script(type='text/javascript', src='/javascript/socket.io.min.js')
script(type='text/javascript')
socket = new io.Socket('localhost', 3000);
socket.connect();
socket.on('message', function(data) {
});
body
This script is loaded on each page (because it’s my layout page). So on each page, the socket connects to the server socket. That’s my problem, I don’t like this idea.
Is it possible to connect once the client socket to the server socket for every client’s pages ?
In addition, is it possible to load once (per client) the /javascript/socket.io.min.js library ?
Thanks.
Check pjax, I hope it will help you.