This is a simple code size comparison between Protobuf-ES and google-protobuf.
We are generating code for the module buf.build/bufbuild/buf
once with protoc-gen-js from github.com/protocolbuffers/protobuf-javascript,
once with protoc-gen-es from Protobuf-ES. Then we bundle a snippet of code that imports from one generated file
with esbuild, minify the bundle, and compress it like a web server would
usually do. We repeat this for an increasing number of files.
Tabular data
| code generator | files | bundle size | minified | compressed |
|---|---|---|---|---|
| Protobuf-ES | 1 | 134,299 b | 69,435 b | 16,004 b |
| Protobuf-ES | 4 | 136,488 b | 70,942 b | 16,731 b |
| Protobuf-ES | 8 | 139,250 b | 72,713 b | 17,235 b |
| Protobuf-ES | 16 | 149,700 b | 80,694 b | 19,551 b |
| Protobuf-ES | 32 | 177,491 b | 102,712 b | 25,074 b |
| protobuf-javascript | 1 | 314,120 b | 244,024 b | 35,999 b |
| protobuf-javascript | 4 | 340,137 b | 258,996 b | 37,473 b |
| protobuf-javascript | 8 | 360,931 b | 270,573 b | 38,585 b |
| protobuf-javascript | 16 | 518,906 b | 363,964 b | 45,793 b |
| protobuf-javascript | 32 | 1,286,214 b | 854,395 b | 75,520 b |