Choose a version:
100% The original file has 62783 bytes (61.3k) and is available from the project website.
There you can find the official minified version, too, which brings down the size to 62783 bytes (61.3k, 100%).

After GZIP compression these minified files vary in size:
gzip -6 (default)
  19273 bytes (18.8k)
local copy
gzip -9
  19186 bytes (18.7k)
local copy
Boot
  18730 bytes (18.3k)
CDN
cdnjs
  18730 bytes (18.3k)
CDN
7zip -mx=9 -tgzip
  18526 bytes (18.1k)
local copy
libdeflate -12
  18519 bytes (18.1k)
local copy
zultra
  18479 bytes (18.0k)
local copy
pigz -11 -n
  18446 bytes (18.0k)
local copy
kzip -s0 -rn -b3
  18401 bytes (18.0k)
local copy
Zopfli
  18374 bytes (17.9k)
local copy

perma-link to the smallest file on my server:
http://minime.stephan-brumme.com/files/socketio/socket.io-2.4.0.min.js (or via HTTPS)

You will automatically get the smallest Socket.IO 2.4.0 file, ETag caching is available and
if your browser doesn't support GZIP decompression then the uncompressed version will be sent.

Currently best Zopfli settings

You can use my super-compressed files for whatever purpose you like as long as you respect the library's original license agreement.
There are no restrictions from my side - but please avoid hot-linking if you run a high-traffic website.

These command-line settings yielded the best compression ratio so far (Linux version of zopfli-krzymod):
zopfli --i1000000 --mb8 --mls32768 --bsr17 --lazy --ohh

(found January 28, 2021)
Description Value Parameter
iterations 1000000  --i1000000
maximum blocks 8  --mb8
maximum length score 32768  --mls32768
block splitting recursion 17  --bsr17
lazy matching in LZ77 yes  --lazy
optimized Huffman headers yes  --ohh
initial random W for iterations 1  --rw1
initial random Z for iterations 2  --rz2

Verify file integrity

After decompression, my uncompressed files are identical to the original ones:

MD5:
curl --silent --compressed https://raw.githubusercontent.com/socketio/socket.io-client/2.4.0/socket.io.min.js --location | md5sum
f381640e658bbcad09bf8b0c73c7c0fb  -
curl --silent --compressed https://minime.stephan-brumme.com/files/socket.io/socket.io-2.4.0.min.zopfli.js.gz | md5sum
f381640e658bbcad09bf8b0c73c7c0fb  -

SHA1:
curl --silent --compressed https://raw.githubusercontent.com/socketio/socket.io-client/2.4.0/socket.io.min.js --location | sha1sum
085e2f5ca7e9da0fe358f28bc4039675f1303369  -
curl --silent --compressed https://minime.stephan-brumme.com/files/socket.io/socket.io-2.4.0.min.zopfli.js.gz | sha1sum
085e2f5ca7e9da0fe358f28bc4039675f1303369  -

CDN Size (compressed) MD5 (uncompressed) Comment / Diff Timestamp
Boot 18730 bytes 317a4bdb3594bd5a786e1fb85d2482a1 < /*!
< * Socket.IO v2.4.0
< * (c) 2014-2021 Guillermo Rauch
< * Released under the MIT License.
< */
< !function(t,e){"object"==typeof exports&&"object"==typeof [...]
< this.transport.removeAllListeners(),this.readyState="close [...]
< var h,f,l,d=String.fromCharCode;t.exports={version:"2.1.2" [...]
< //# sourceMappingURL=socket.io.js.map
> !function(t,e){"object"==typeof exports&&"object"==typeof [...]
(invalid)
cdnjs 18730 bytes 317a4bdb3594bd5a786e1fb85d2482a1 < /*!
< * Socket.IO v2.4.0
< * (c) 2014-2021 Guillermo Rauch
< * Released under the MIT License.
< */
< !function(t,e){"object"==typeof exports&&"object"==typeof [...]
< this.transport.removeAllListeners(),this.readyState="close [...]
< var h,f,l,d=String.fromCharCode;t.exports={version:"2.1.2" [...]
< //# sourceMappingURL=socket.io.js.map
> !function(t,e){"object"==typeof exports&&"object"==typeof [...]
(invalid)

Note: only the MD5 hashes are shown to keep things simple.

Other Versions

Available Socket.IO versions at minime.stephan-brumme.com:

4.5.4, 4.5.3, 4.5.2, 4.5.1, 4.5.0, 4.4.1, 4.4.0, 4.3.2, 4.3.1, 4.3.0, 4.2.0, 4.1.3, 4.1.2, 4.1.1, 4.1.0, 4.0.2, 4.0.1, 4.0.0,
3.1.2, 3.1.1, 3.1.0, 3.0.5, 3.0.4, 3.0.3, 3.0.2, 3.0.1, 3.0.0,
2.4.0, 2.3.1, 2.3.0, 2.2.0, 2.1.1, 2.1.0, 2.0.4, 2.0.3, 2.0.2, 2.0.1, 2.0.0,
1.7.4, 1.7.2, 1.7.1, 1.7.0, 1.6.0, 1.5.0, 1.4.5, 1.4.4, 1.4.3, 1.4.2, 1.4.1, 1.4.0, 1.3.7, 1.3.6, 1.3.5, 1.3.4, 1.3.3, 1.3.2, 1.3.1, 1.3.0, 1.2.1, 1.2.0, 1.1.0, 1.0.6, 1.0.5, 1.0.4, 1.0.3, 1.0.2, 1.0.1, 1.0.0

The project site contains an overview how well these versions were compressed.
Other interesting projects are AngularJS, BackboneJS, Bootstrap, D3, Dojo, Ember, jQuery, Knockout, lodash, React, ThreeJS, UnderscoreJS and Vue.

Changelog

Best Zopfli parameters so far:
Size Improvement Parameters Found
18374 bytes -2 bytes zopfli --i1000000 --mls32768 --bsr17 --lazy --ohh January 28, 2021 @ 12:41
18376 bytes -2 bytes zopfli --i100000 --mls32768 --bsr17 --lazy --ohh January 28, 2021 @ 01:11
18378 bytes -1 byte zopfli --i10000 --mls32768 --bsr17 --lazy --ohh January 27, 2021 @ 17:22
18379 bytes -3 bytes zopfli --i10000 --mls32768 --bsr40 --lazy --ohh January 27, 2021 @ 17:11
18382 bytes -2 bytes zopfli --i1000 --mls32768 --bsr17 --lazy --ohh January 27, 2021 @ 16:17
18384 bytes -9 bytes zopfli --i1000 --mls32768 --bsr40 --lazy --ohh January 27, 2021 @ 16:17
18393 bytes zopfli --i100 --mls32768 --bsr40 --lazy --ohh January 25, 2021 @ 08:50

If there are multiple parameter sets yielding the same compressed size, only the first one found is shown.

Most recent activity on January 28, 2021 @ 13:29.

Heatmaps

This Zopfli heatmap visualizes how compression changes when modifying the --bsr and --mls parameter.
Cell's contents is the best filesize achieved (in bytes, hover with mouse over cells to see number of iterations).

Good parameters are green, bad are red. The best and worst are bold as well.
The brightness of the blue background color indicates how many iterations were processed:
10,000, 100,000 or 1,000,000.
bsr \ mls
2 4 8 16 32 64 128 256 512 1024 2048 4096 8192 16384 32768
bsr \ mls
2 4 8 16 32 64 128 256 512 1024 2048 4096 8192 16384 32768
18438 18439 18432 18434 18437 18437 18441 18438 18440 18433 18434 18444 18416 18434 18446
18426 18426 18423 18426 18425 18422 18428 18426 18425 18431 18428 18440 18439 18442 18436
18424 18426 18428 18424 18425 18424 18428 18424 18429 18431 18424 18426 18435 18443 18441
18423 18422 18429 18427 18421 18421 18429 18429 18429 18425 18424 18429 18435 18442 18439
18430 18430 18425 18432 18424 18428 18424 18422 18423 18434 18429 18429 18440 18442 18438
18425 18426 18424 18426 18424 18422 18431 18427 18429 18431 18425 18432 18436 18418 18436
18428 18432 18428 18426 18430 18428 18428 18429 18425 18428 18426 18429 18436 18442 18434
18424 18423 18424 18425 18425 18429 18419 18420 18429 18432 18426 18429 18437 18441 18406
18430 18422 18428 18424 18425 18426 18423 18419 18424 18427 18424 18429 18436 18391 18434
18425 18425 18426 18422 18422 18427 18424 18426 18426 18427 18429 18435 18435 18443 18442
18430 18422 18425 18435 18424 18423 18424 18420 18426 18425 18425 18431 18435 18443 18434
18425 18422 18427 18428 18426 18421 18420 18427 18430 18431 18424 18429 18435 18443 18435
18430 18429 18422 18422 18426 18424 18421 18421 18425 18427 18425 18431 18436 18442 18435
18423 18424 18428 18432 18424 18421 18427 18421 18427 18428 18430 18430 18438 18440 18374
18424 18423 18425 18426 18427 18425 18421 18421 18430 18427 18426 18432 18436 18442 18434
18424 18425 18425 18427 18426 18428 18420 18421 18428 18431 18424 18430 18434 18443 18434
18423 18426 18427 18424 18423 18426 18425 18419 18422 18429 18424 18430 18437 18440 18434
18422 18426 18423 18427 18427 18429 18426 18426 18425 18427 18427 18431 18437 18442 18414
18422 18425 18428 18424 18427 18425 18429 18426 18428 18427 18424 18430 18439 18442 18433
18423 18426 18425 18424 18425 18432 18419 18422 18429 18430 18426 18424 18436 18442 18434
18422 18422 18424 18426 18425 18426 18428 18429 18429 18428 18424 18431 18435 18444 18434
18430 18432 18428 18427 18424 18422 18420 18420 18424 18427 18425 18429 18436 18444 18433
18424 18422 18422 18427 18422 18424 18420 18429 18426 18428 18423 18436 18438 18437 18377

Due to the Monte Carlo design of my search algorithm, not all parameters have reached the same number of iterations yet:
Iterations Min. Bytes Reduction Coverage
100 18393 bytes 100%
1,000 18382 bytes -11 bytes 100%
10,000 18378 bytes -4 bytes 100%
100,000 18376 bytes -2 bytes 0.58%
1,000,000 18374 bytes -2 bytes 0.29%
10,000,000

KZIP has far less options available for tuning/optimization. I only played around with the number of blocks (parameter -n):
Blocks Min. Bytes Compared To Best Zopfli Compared To Best KZIP
18401 bytes +27 bytes (+0.15%)
18502 bytes +128 bytes (+0.70%) +101 bytes
18445 bytes +71 bytes (+0.39%) +44 bytes
18401 bytes +27 bytes (+0.15%)
18407 bytes +33 bytes (+0.18%) +6 bytes
18423 bytes +49 bytes (+0.27%) +22 bytes
18419 bytes +45 bytes (+0.24%) +18 bytes
18439 bytes +65 bytes (+0.35%) +38 bytes
18470 bytes +96 bytes (+0.52%) +69 bytes

Non-DEFLATE Algorithms

Archivers based on completely different compression algorithms often produce superior results.
Unfortunately, browsers only support gzip compression at the moment.
However, support for Brotli is constantly growing - but your browser doesn't support it.
Algorithm Program Parameters Size Compared To Best Zopfli
ZPAQ (Wikipedia) zpaq zpaq -method 69 15409 bytes -2965 bytes (-16.14%)
Brotli (Wikipedia) brotli brotli -q 11 16992 bytes -1382 bytes (-7.52%)
Burrows-Wheeler transform (Wikipedia) bzip2 bzip2 -9 17599 bytes -775 bytes (-4.22%)
LZMA2 (Wikipedia) xz xz -9 17780 bytes -594 bytes (-3.23%)
Zstandard (Wikipedia) zstd zstd -19 18059 bytes -315 bytes (-1.71%)
PPMd (Wikipedia) 7zip 7za a -mx=9 -m0=ppmd 2287493 bytes +2269119 bytes (+12,349.62%)
RAR (proprietary) RAR rar a -m5 -md64m -mc63:128t -mt1 4974252 bytes +4955878 bytes (+26,972.23%)

Detailled Analysis

I wrote a DEFLATE decoder in Javascript. Click the button below to start a client-side analysis of the smallest gzipped files (may take a second):


Notes: pigz is a fast open source multi-threaded implementation of gzip written by one of the original authors of gzip.
However, when using compression level 11, pigz actually switches to the slower Zopfli algorithm and isn't multi-threaded anymore.
KrzyMOD's extensions to Zopfli offer the highest level of configuration and is therefore used for my brute-force search.
Ken Silverman wrote the closed-source KZIP compression program and Jonathon Fowler ported it to Linux.
Defluff was created by Joachim Henke; DeflOpt is a tool by Ben Jos Walbeehm.

website made by Stephan Brumme in 2015 and still improving in 2024.
all timestamps are displayed in central european time. see my changelog.
no flash, not even images or external css files - and everything squeezed into a single html file.
which was handsomely compressed before releasing it into the wild internet - obviously.

please visit my homepage and my blog, too.
email: minime (at) stephan-brumme.com

All trademarks are property of their respective owners. You know, the boring legal stuff.