Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

minify /socket.io/socket.io.js with 1.0

Tags:

socket.io

Today 1.0 of socket.io has been released. I just updated and now the following isn't working anymore:

io.enable('browser client minification');
io.enable('browser client etag');
io.enable('browser client gzip');

The new documentation seems not to be complete yet, how to minify and enable gzip+etag with 1.0 ?

like image 647
Daniel W. Avatar asked Jun 01 '14 16:06

Daniel W.


2 Answers

It seems this is not possible with 1.0 - recursive search in the socket.io folder with words like "gzip", "etag", and "minif" does not provide any relevant results. Besides in previous versions there was a socket.io.min.js file near socket.io.js. Now it is absent.

Maybe the following solution is not satisfying, but in case you're using nginx (or other webserver) in front of node you can serve socket.io.js (manually compressed by Google Closure Compiler for example) with your own. You can enable gzip and etag on nginx as well.

like image 130
Oleg Avatar answered Sep 20 '22 15:09

Oleg


Check this out: http://socket.io/blog/introducing-socket-io-1-0/

CDN delivery

One of the best decisions we made early on was that implementing a Socket.IO server would not only give you access to the realtime protocol, but Socket.IO itself would also serve the client.

Normally, all you have to do is to include a snippet like this:

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

If you want to optimize access to the client by serving it near your users, provide the maximum level of gzip compression (thanks to Google’s zopfli and proper support for caching, you can now use our CDN. It’s free, forever, and has built-in SSL support:

<script src="https://cdn.socket.io/socket.io-1.0.0.js"></script>

Also, if you are migrating from 0.9: http://socket.io/docs/migrating-from-0-9/

like image 28
Eliseo Castilla Avatar answered Sep 20 '22 15:09

Eliseo Castilla