Use ZLIB compression on the traces
Use ZLIB compression on the traces

We have found by looking at typical plots that the trace data is often
quite large and takes up the bulk of the size of the plots. As we
directly handle the display of traces via selection, it is a simple
matter for us to compress them before writing out the notebook and
decompress them before we show some selected subset. Given our
brief testing of speed and compression, we have found that ZLIB
compression works reasonably well. As such, we have implemented ZLIB
compression of the traces on the Python side to reduce the HTML size and
handle ZLIB decompression on the JavaScript side so as to correctly
display them.

In Python, ZLIB is available via the standard library. It is a
relatively trivial manner to then get the NumPy array buffer for the
traces and run ZLIB compression on it. Storing this back as a `uint8`
NumPy array, we can be sure that Bokeh will store this in an efficient
manner by using `base64` encoding. This takes care of efficiently
storing the trace data. However, we still have to use this data
correctly in JavaScript.

While compression is not generally available in JavaScript, there are a
variety of libraries that implement the basic compression algorithms
like ZLIB in JavaScript. After a cursory look through the options, pako
meets our requirements. The library provides a fast, pure JavaScript
implementation of ZLIB. As they provide a minimized CDN, we can easily
pull in the dependency through the user's browser so it is available at
run time (just as is already done with Bokeh). The library is also under
the permissive MIT license. So it doesn't put us in any weird legal
situations w.r.t. distribution of the plots or the code.

Given all of these changes, we are able to reduce the size of our plots
while still being able to ship them in regular HTML without having to
compress them afterwards. As the requirements can still easily be
handled by the browser and an internet connection, this should add no
new constraints on users that wish to work with these more compact
plots.

DudLab/nanshe_workflow,nanshe-org/nanshe_workflow