Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compression on build #27

Open
dead-claudia opened this issue Aug 16, 2014 · 2 comments
Open

Compression on build #27

dead-claudia opened this issue Aug 16, 2014 · 2 comments

Comments

@dead-claudia
Copy link

The udata variable obviously has size issues, already pointed out in #17, but I was thinking that pre-compressing it in the build phase would be able to significantly cut it down in size. For example, using the following process to compress that variable's content:

  1. Stringify the JSON.
  2. Compress it with bzip2 (near the top in both speed and efficiency).
  3. Base64-encode it. This will help remove some redundancy.
  4. Include that as a string in the built source.

And then, on load or first use on the target side:

  1. Decode it.
  2. Decompress it. (should be significantly faster than compression)
  3. Parse the JSON.
  4. Ready to use.
@dead-claudia
Copy link
Author

Also, a suggestion of a potentially good library: https://github.com/cscott/compressjs

@phadej
Copy link
Collaborator

phadej commented Aug 17, 2014

TL:DR if you worry about wire-transfer size, use gzip compression. This kind of size optimisation is job of build tool, not library maintainers.

The udata is big, but is very compressable (minimsation in between helps only marginally):

% ll lib 
-rw-r--r--  1 phadej  staff  141692 Aug 17 14:31 unorm.js
-rw-r--r--  1 phadej  staff   38186 Aug 17 14:33 unorm.js.gz
-rw-r--r--  1 phadej  staff   34046 Aug 17 14:35 unorm.js.bz2
-rw-r--r--  1 phadej  staff   21832 Aug 17 14:42 unorm.js.xz
-rw-r--r--  1 phadej  staff  136811 Aug 17 14:33 unorm.min.js
-rw-r--r--  1 phadej  staff   36773 Aug 17 14:33 unorm.min.js.gz

bzip2 does compress is better than gzip, but not that much. I'd use xz. Though for all javascripts. not only one part of single of them.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants