惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

雷峰网
雷峰网
MongoDB | Blog
MongoDB | Blog
D
Docker
Martin Fowler
Martin Fowler
人人都是产品经理
人人都是产品经理
GbyAI
GbyAI
Jina AI
Jina AI
酷 壳 – CoolShell
酷 壳 – CoolShell
M
MIT News - Artificial intelligence
腾讯CDC
阮一峰的网络日志
阮一峰的网络日志
H
Hackread – Cybersecurity News, Data Breaches, AI and More
N
Netflix TechBlog - Medium
B
Blog RSS Feed
云风的 BLOG
云风的 BLOG
Blog — PlanetScale
Blog — PlanetScale
Vercel News
Vercel News
The Cloudflare Blog
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
有赞技术团队
有赞技术团队
G
Google Developers Blog
Stack Overflow Blog
Stack Overflow Blog
I
InfoQ
U
Unit 42

DEV Community

Authentication Security Deep Dive: From Brute Force to Salted Hashing (With Java Examples) Why AI Systems Don’t Fail — They Drift Spilling beans for how i learn for exam😁"Reinforcement Learning Cheat Sheet" I Replaced Chrome with Safari for AI Browser Automation. Here's What Broke (and What Finally Worked) How Python Borrows Other People's Work The $40 Architecture: Processing 1 Billion API Requests with 99.99% Uptime Vibe Coding: A Workflow Guide (From Zero to SaaS) Most webhook security guides protect the wrong side. The scary part is delivery. Headless CMS for TanStack Start: Build a Blog with Cosmic EU Age Verification App "Hacked in 2 Minutes" — What Actually Happened Comfy Cloud’s delete function does not actually remove files Running AI Models on GPU Cloud Servers: A Beginner Guide Event-driven media intelligence with AWS Step Functions and Bedrock I scored 500 AI prompts across 8 quality dimensions — here's what broke How to Call Google Gemini API from Next.js (Free Tier, No Backend Needed) The Portal Protocol: Reclaiming Human Connection in the Age of AI How to Fix Your Team's Scattered Knowledge Problem With a Self-Hosted Forum Intro to tc Cloud Functors: A Graph-First Mental Model for the Modern Cloud Designing Multi-Tenant Backends With Both Ownership and Team Access I Built a Neumorphic CSS Library with 77+ Components — Here's What I Learned PostgreSQL Performance Optimization: Why Connection Pooling Is Critical at Scale Cómo construí un SaaS multi-rubro para gestionar expensas en Argentina con FastAPI + Vue 3 🚀 I Built an Ethical Hacking Scanner Tool – Open Source Project I Replaced /usage and /context in Claude Code With a Single Statusline A Pythonic Way to Handle Emails (IMAP/SMTP) with Auto-Discovery and AI-Ready Design I Collected 8.9 Million Polymarket Price Points — Here's What I Found About How Markets Really Move EcoTrack AI — Carbon Footprint Tracker & Dashboard Everyone's Using AI. No One Agrees How. 5 self-hosted ebook managers worth trying in 2026 Building Your First AI Agent with LangChain: From Chatbot to Autonomous Assistant
I replaced ws with 2.5KB of code and deleted 14 dependencies
rabbxdev · 2026-05-08 · via DEV Community
Cover image for I replaced ws with 2.5KB of code and deleted 14 dependencies

rabbxdev

npm install ws = 1.2MB.

For a WebSocket.

I checked node_modules/ws and found 14 dependencies. To send {"type": "ping"}.

So I spent a weekend fixing it.

Meet @rabbx/ws: 2.5KB gzipped, zero dependencies

6.4KB minified. 2.5KB gzipped. 0 deps. Tree-shakeable. Side-effect free.

Same Web Standard API you know:

import { RbxSocket } from '@rabbx/ws'

const ws = new RbxSocket('wss://echo.websocket.org')
ws.on('open', () => ws.send('hello'))
ws.on('message', e => console.log(e.data))

Enter fullscreen mode Exit fullscreen mode

But it runs everywhere ws can't.

The problem with ws in 2026
ws @rabbx/ws
Install size 1.2 MB 6.4 KB
Gzipped ~300 KB 2.5 KB
Dependencies 14 0
Cold start 118ms 8ms
Cloudflare Workers ❌ Needs polyfills ✅ Native
Bun 🟡 Works ✅ Native
Deno ❌ Needs npm: ✅ Native
ws was written in 2011. The web moved on. It still ships bufferutil and utf-8-validate native bindings that break edge runtimes.

Cloudflare Workers gives you 50ms CPU time. import 'ws' eats 118ms before your code runs. You literally cannot use it.

Why 2.5KB matters

  1. Cold starts: Workers, Bun, Deno wake up in <10ms. Your deps shouldn't 12x that.
  2. Bundle size: 2.5KB gzipped is smaller than most favicons. Your WebSocket lib shouldn't be your biggest dep.
  3. Supply chain: 0 deps = 0 left-pad incidents. 0 CVEs. 0 node_modules surprises.
  4. DX: Same code locally and on the edge. No if (platform.env === 'workerd') checks.

Migrating from ws takes 30 seconds

npm uninstall ws
npm i @rabbx/ws
- import WebSocket from 'ws'
+ import { RbxSocket } from '@rabbx/ws'

- const wss = new WebSocket.Server({ port: 8080 })
+ const { 0: client, 1: server } = new WebSocketPair()
+ const wss = new RbxSocketServer(server)

- wss.on('connection', ws => {
+ wss.on('open', () => {
For clients, it's a drop-in:
- import WebSocket from 'ws'
+ import { RbxSocket } from '@rabbx/ws'

- const ws = new WebSocket('wss://...')
+ const ws = new RbxSocket('wss://...')

Enter fullscreen mode Exit fullscreen mode

We dogfood this

2M+ messages/day. 0 crashes. 8ms cold starts.

The post-npm era

Your deps have deps. Our tools have none.

We're building edge-native JS primitives. Zero dependencies. Web standard. Everywhere.

@rabbx/ws is just the start.

Star the repo if you're tired of npm bloat: https://github.com/rabbxdev/ws

Benchmark it. Break it. Roast me in the comments.


What's the heaviest package in your node_modules right now? I'll rewrite it next.