Skip to content

Commit ed86f3a

Browse files
committed
README on minimal runtime / available downloads [ci skip]
1 parent a54fbc9 commit ed86f3a

File tree

4 files changed

+34
-30
lines changed

4 files changed

+34
-30
lines changed

README.md

+28-26
Original file line numberDiff line numberDiff line change
@@ -77,10 +77,12 @@ Production:
7777
<script src="//cdn.rawgit.com/dcodeIO/protobuf.js/6.1.0/dist/protobuf.min.js"></script>
7878
```
7979

80-
The `protobuf` namespace will be available globally.
81-
8280
**NOTE:** Remember to replace the version tag with the exact [release](https://github.com/dcodeIO/protobuf.js/releases) your project depends upon.
8381

82+
Or [download](https://github.com/dcodeIO/protobuf.js/tree/master/dist) the library.
83+
84+
The `protobuf` namespace will always be available globally but also supports AMD.
85+
8486
Examples
8587
--------
8688

@@ -336,14 +338,6 @@ protobuf.load("bundle.json", function(err, root) {
336338
});
337339
```
338340

339-
### Descriptors vs. static modules
340-
341-
While .proto and JSON files require the full library (about 20kb gzipped), pretty much all code but the relatively short descriptors is shared.
342-
343-
Static code, on the other hand, requires just the runtime library (about 5kb gzipped), but generates relatively large code bases without any reflection features.
344-
345-
When `new Function` is supported (and it usually is), there is no difference performance-wise as the code generated statically is the same generated at runtime.
346-
347341
### Generating TypeScript definitions from static modules
348342

349343
Likewise, the `pbts` command line utility can be used to generate TypeScript definitions from `pbjs`-generated static modules.
@@ -358,6 +352,14 @@ Generates TypeScript definitions from annotated JavaScript files.
358352
usage: pbts [options] file1.js file2.js ...
359353
```
360354

355+
### Descriptors vs. static modules
356+
357+
While .proto and JSON files require the full library (about 18kb gzipped), pretty much all code but the relatively short descriptors is shared.
358+
359+
Static code, on the other hand, requires just the minimal runtime (about 5.5kb gzipped), but generates relatively large code bases without any reflection features.
360+
361+
When `new Function` is supported (and it usually is), there is no difference performance-wise as the code generated statically is the same generated at runtime.
362+
361363
Building
362364
--------
363365

@@ -404,37 +406,37 @@ The package includes a benchmark that tries to compare performance to native JSO
404406
```
405407
benchmarking encoding performance ...
406408
407-
Type.encode to buffer x 479,876 ops/sec ±0.64% (92 runs sampled)
408-
JSON.stringify to string x 311,489 ops/sec ±0.84% (87 runs sampled)
409-
JSON.stringify to buffer x 175,079 ops/sec ±1.48% (82 runs sampled)
409+
Type.encode to buffer x 481,172 ops/sec ±0.48% (92 runs sampled)
410+
JSON.stringify to string x 307,509 ops/sec ±1.04% (92 runs sampled)
411+
JSON.stringify to buffer x 164,463 ops/sec ±1.37% (89 runs sampled)
410412
411413
Type.encode to buffer was fastest
412-
JSON.stringify to string was 35.2% slower
413-
JSON.stringify to buffer was 63.8% slower
414+
JSON.stringify to string was 36.4% slower
415+
JSON.stringify to buffer was 66.1% slower
414416
415417
benchmarking decoding performance ...
416418
417-
Type.decode from buffer x 1,267,612 ops/sec ±1.18% (90 runs sampled)
418-
JSON.parse from string x 291,707 ops/sec ±1.12% (92 runs sampled)
419-
JSON.parse from buffer x 262,640 ops/sec ±0.77% (89 runs sampled)
419+
Type.decode from buffer x 1,319,810 ops/sec ±0.71% (92 runs sampled)
420+
JSON.parse from string x 298,578 ops/sec ±0.98% (90 runs sampled)
421+
JSON.parse from buffer x 267,471 ops/sec ±0.81% (89 runs sampled)
420422
421423
Type.decode from buffer was fastest
422-
JSON.parse from string was 77.0% slower
423-
JSON.parse from buffer was 79.2% slower
424+
JSON.parse from string was 77.4% slower
425+
JSON.parse from buffer was 79.8% slower
424426
425427
benchmarking combined performance ...
426428
427-
Type to/from buffer x 248,897 ops/sec ±0.89% (90 runs sampled)
428-
JSON to/from string x 126,848 ops/sec ±0.75% (92 runs sampled)
429-
JSON to/from buffer x 89,854 ops/sec ±0.79% (93 runs sampled)
429+
Type to/from buffer x 262,728 ops/sec ±0.92% (92 runs sampled)
430+
JSON to/from string x 129,405 ops/sec ±0.78% (94 runs sampled)
431+
JSON to/from buffer x 89,523 ops/sec ±0.71% (89 runs sampled)
430432
431433
Type to/from buffer was fastest
432-
JSON to/from string was 49.0% slower
433-
JSON to/from buffer was 63.9% slower
434+
JSON to/from string was 50.7% slower
435+
JSON to/from buffer was 65.9% slower
434436
435437
benchmarking verifying performance ...
436438
437-
Type.verify x 5,941,014 ops/sec ±0.96% (90 runs sampled)
439+
Type.verify x 5,833,382 ops/sec ±0.98% (85 runs sampled)
438440
439441
Type.verify was fastest
440442
```

dist/README.md

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
This folder contains prebuilt browser versions of [protobuf.js](https://github.com/dcodeIO/protobuf.js). When sending pull requests, it is not required to update these.
22

3+
Alternatively, you can also use [the minimal runtime](./runtime) when working with statically generated code from `pbjs` *only*.
4+
35
Prebuilt files are in source control to enable pain-free frontend respectively CDN usage:
46

57
CDN usage

dist/runtime/README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
This folder contains prebuilt browser versions of [protobuf.js](https://github.com/dcodeIO/protobuf.js)'s runtime for statically generated code. When sending pull requests, it is not required to update these.
1+
This folder contains prebuilt browser versions of [protobuf.js](https://github.com/dcodeIO/protobuf.js)'s minimal runtime for statically generated code. When sending pull requests, it is not required to update these.
22

3-
**NOTE:** The static code runtime includes just the bare minimum required to work with statically generated modules - and *nothing else*. Where applicable, it can be used as a drop-in replacement for the full library as it has the same general structure.
3+
**NOTE:** The minimal runtime includes just the bare minimum required to work with statically generated code - and *nothing else*. Where applicable, it can be used as a drop-in replacement for the full library as it has the same general structure.
44

55
Prebuilt files are in source control to enable pain-free frontend respectively CDN usage:
66

package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "protobufjs",
3-
"version": "6.1.0",
4-
"description": "Protocol Buffers for JavaScript.",
3+
"version": "6.1.1",
4+
"description": "Protocol Buffers for JavaScript (& TypeScript).",
55
"author": "Daniel Wirtz <[email protected]>",
66
"license": "Apache-2.0",
77
"repository": {

0 commit comments

Comments
 (0)