A super efficient, high-performance binary parser for Socket.IO based on the MessagePack specification.
This parser is designed to be a modern, lightweight replacement for the default JSON parser, significantly reducing the payload size of your real-time communication.
Current version: 1.0.0
- Fully implements the Socket.IO Parser API.
- Powered by
notepack.iofor ultra-fast MessagePack encoding/decoding. - Bundles
@socket.io/component-emitterfor a seamless browser experience. - Supports both ES Modules (ESM) and CommonJS (CJS).
Roadmap:
- Implementation of custom dictionary-based text compression to further reduce string overhead.
- Integration with native browser CompressionStream API for large payloads.
npm install socket.io-compact-parserYou can include the parser directly in your HTML via unpkg. It is bundled as a UMD module, making it available as a global variable.
<script src="https://unpkg.com/socket.io-compact-parser/dist/browser.min.js"></script>import { Server } from "socket.io";
import CompactParser from "socket.io-compact-parser";
const io = new Server(server, {
parser: CompactParser
});import { io } from "socket.io-client";
import CompactParser from "socket.io-compact-parser";
const socket = io({
parser: CompactParser
});<script src="/socket.io/socket.io.js"></script>
<script src="https://unpkg.com/socket.io-compact-parser/dist/browser.min.js"></script>
<script>
const socket = io({
parser: SocketIOCompactParser
});
</script>The default Socket.IO parser uses JSON, which is text-based and can become quite large when sending complex objects or binary data. By using MessagePack via socket.io-compact-parser, your data is converted into a compact binary format, leading to:
- Lower bandwidth usage.
- Faster serialization/deserialization.
- Better handling of binary data (Buffers/Uint8Arrays).
This project is licensed under the MIT License.
- Wilco Joosen (computer-wilco) - Lead Developer