All Projects → gfx → Universal Zopfli Js

gfx / Universal Zopfli Js

Licence: other
JavaScript binding to Zopfli with WebAssembly.

Programming Languages

typescript
32286 projects

Projects that are alternatives of or similar to Universal Zopfli Js

Denoflate
WebAssembly powered Deflate/Gzip/Zlib compression for Deno, written in Rust
Stars: ✭ 80 (+14.29%)
Mutual labels:  zlib, wasm, gzip
em inflate
Fast, small, in-memory inflate (zlib, deflate and gzip decompression)
Stars: ✭ 59 (-15.71%)
Mutual labels:  gzip, zlib
Turbobench
Compression Benchmark
Stars: ✭ 211 (+201.43%)
Mutual labels:  zlib, gzip
power-gzip
POWER9 gzip engine documentation and code samples
Stars: ✭ 16 (-77.14%)
Mutual labels:  gzip, zlib
Libflate
A Rust implementation of DEFLATE algorithm and related formats (ZLIB, GZIP)
Stars: ✭ 125 (+78.57%)
Mutual labels:  zlib, gzip
Uzlib
Radically unbloated DEFLATE/zlib/gzip compression/decompression library. Can decompress any gzip/zlib data, and offers simplified compressor which produces gzip-compatible output, while requiring much less resources (and providing less compression ratio of course).
Stars: ✭ 168 (+140%)
Mutual labels:  zlib, gzip
zzlib
zlib-compressed file depacking library in Lua
Stars: ✭ 44 (-37.14%)
Mutual labels:  gzip, zlib
Libarchivejs
Archive library for browsers
Stars: ✭ 145 (+107.14%)
Mutual labels:  wasm, gzip
zlib
Compression and decompression in the gzip and zlib formats
Stars: ✭ 32 (-54.29%)
Mutual labels:  gzip, zlib
deflate-rs
An implementation of a DEFLATE encoder in rust
Stars: ✭ 47 (-32.86%)
Mutual labels:  gzip, zlib
Tinf
Tiny inflate library (inflate, gzip, zlib)
Stars: ✭ 57 (-18.57%)
Mutual labels:  zlib, gzip
Swcompression
A Swift framework for working with compression, archives and containers.
Stars: ✭ 110 (+57.14%)
Mutual labels:  zlib, gzip
Zippy
Pure Nim implementation of deflate, zlib, gzip and zip.
Stars: ✭ 88 (+25.71%)
Mutual labels:  zlib, gzip
Datacompression
Swift libcompression wrapper as an extension for the Data type (GZIP, ZLIB, LZFSE, LZMA, LZ4, deflate, RFC-1950, RFC-1951, RFC-1952)
Stars: ✭ 191 (+172.86%)
Mutual labels:  zlib, gzip
Gzipswift
Swift framework that enables gzip/gunzip Data using zlib
Stars: ✭ 356 (+408.57%)
Mutual labels:  zlib, gzip
Libz.jl
Fast, flexible zlib bindings.
Stars: ✭ 26 (-62.86%)
Mutual labels:  gzip, zlib
zlib
Pure javascript implementation of Zlib nodejs core module.The zlib module provides compression functionality implemented using Gzip and Deflate/Inflate.
Stars: ✭ 14 (-80%)
Mutual labels:  gzip, zlib
python-isal
Faster zlib and gzip compatible compression and decompression by providing python bindings for the isa-l library.
Stars: ✭ 21 (-70%)
Mutual labels:  gzip, zlib
Flate2 Rs
DEFLATE, gzip, and zlib bindings for Rust
Stars: ✭ 390 (+457.14%)
Mutual labels:  zlib, gzip
Redshirt
🧑‍🔬 Operating system
Stars: ✭ 1,082 (+1445.71%)
Mutual labels:  wasm

Universal Zopfli npm version Build Status

google/zopfli is a compression library to perform gzip, deflate or zlib compression.

This library is a JavaScript binding to zopfli with WebAssembly. This is slower than native extensions for zopfli, but because wasm is a portable binary format, its installation is much easier than native extensions.

Installation

# for npm users:
npm install "@gfx/zopfli"

# for yarnpkg users
yarnpkg add "@gfx/zopfli"

Usage

In TypeScript:

import { gzip, zlib, deflate } from "@gfx/zopfli";

const input: string;
gzip(input, { numiterations: 15 }, (err, output) => {
    // output is compressed in gzip
});

Note that the gzip method is compatible with node-zopfli.

Options

Exported as ZopfliOptions and its default is:

const defaultOptions: ZopfliOptions = {
    verbose: false,
    verbose_more: false,
    numiterations: 15,
    blocksplitting: true,
    blocksplittingmax: 15,
};

Using Zopfli with promises for async/await

There are "async"-suffixed versions that return promises:

// These functions return `Promise<T>` for async/await.
import { gzipAsync, zlibAsync, deflateAsync } from "@gfx/zopfli";

Using Zopfli in Webpack CompressionPlugin

You can give the zopfli.gzip function to CompressionPlugin:

// in webpack.config.js

const CompressionPlugin = require('compression-webpack-plugin');
const { gzip } = require('@gfx/zopfli');

module.exports = {
  plugins: [
    new CompressionPlugin({
      algorithm: gzip,
    }),
  ],
};

Development

Prerequisites

Testing

make

Benchmarking

make benchmark-with-optimization

As of emscripten 1.38.37 with LLVM backend + NodeJS v10.16.0 + macOS 10.14.4, the result is as follows:

## payload size: 1
universal-zopfli x 162 ops/sec ±3.82% (80 runs sampled)
node-zopfli x 185 ops/sec ±3.37% (77 runs sampled)
Fastest is node-zopfli
## payload size: 1024
universal-zopfli x 2.04 ops/sec ±3.48% (14 runs sampled)
node-zopfli x 5.02 ops/sec ±1.03% (28 runs sampled)
Fastest is node-zopfli
## payload size: 1038336
universal-zopfli x 0.33 ops/sec ±6.77% (6 runs sampled)
node-zopfli x 0.32 ops/sec ±17.77% (6 runs sampled)
Fastest is universal-zopfli,node-zopfli

That is, the performance of universal-zopfli is about 50%-75% of native binding node-zopfli with 1KiB-1MiB payload.

See Also

Copyright

Copyright 2017, FUJI Goro (gfx).

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

And it links to google/zopfli statically, which is also licensed by Google under Apache 2.0 License.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].