-
Notifications
You must be signed in to change notification settings - Fork 4
Introduction to JBB

A Javascript Binary Bundle (JBB) is an efficient, binary serialisation and bundling format for Javascript structures and resources. It is similar to BJSON or MessagePack, but it can do much more:
-
It's designed for javascript
Instead of creating yet another binary serialisation format, JBB is designed to be as close to native javascript structures as possible. It optimally usesTypedArrays, with an appropriate file format for this purpose, making it the most efficient solution for the browser. -
It preserves object type information
JBB is aware of object types and it can efficiently encode all or part of their properties according to your specifications. -
It de-duplicates repeating data
JBB can efficiently reduce the size of the final bundle by removing object duplicates from the encoded structure. -
It can efficiently encode
TypedArrays
JBB has a dedicated optimisation mechanism for numerical arrays. It can analyse the numerical values and chose between a variety of encoding types in order to achieve the smallest bundle size possible. -
It can bundle DOM elements and embed the referred files
If you refer to HTML DOM elements, such as<img>or<script>, JBB will automatically embed the source file in the bundle. -
It supports cross-bundle references
You can break your resources into separate bundles and the JBB runtime can seamlessly load them when needed. -
It comes with complete tooling
JBB can be easy integrated to your existing project, either with it'sgulpplugins, or through the command-line utilities.
JBB helps you organise your resources in reusable packages, while in the same time can optimally compact them in binary bundles. These bundles are faster to load (about 30% faster) and easier to share and reuse.
A great example can be found in the world of 3D graphics. Instead of using a different loader for all the different file formats, you can load everything once on a node.js instance and then write them down in a JBB bundle.
JBB is quite slow on encoding, but very fast on decoding and quite efficient on it's size compared to other binary protocols. This makes it an ideal archiving format, but a quite bad streaming encoder. So prefer JBB:
-
If you are loading many resources over AJAX requests
JBB can pack them in a single bundle and load all of them in a single request. -
If you have too many loading formats and you don't want all of them in your run-time
You can use all your existing loaders at compile-time and then use only JBB at run-time. -
If you want to create re-usable bundles of resources (ex. model or texture packages, datasets)
You can pack not only Javascript bundles, but images and other static files too. Therefore a single bundle can contain all the information you need for an entire 3D scene. -
If your data contains lots of numbers or repeating data (ex. 3d meshes, time-series)
JBB is specially optimised for numerical arrays, while it's data de-duplication mechanism can reduce the size even further.