All Projects → contivero → hasmin

contivero / hasmin

Licence: BSD-3-Clause license
Hasmin - A Haskell CSS Minifier

Programming Languages

haskell
3896 projects

Projects that are alternatives of or similar to hasmin

Minify
CSS & JavaScript minifier, in PHP. Removes whitespace, strips comments, combines files (incl. @import statements and small assets in CSS files), and optimizes/shortens a few common programming patterns.
Stars: ✭ 1,710 (+3009.09%)
Mutual labels:  compression, minifier, css-minifier
Gzip
💾 Golang gzip middleware for Gin and net/http | Golang gzip中间件,支持Gin和net/http,开箱即用同时可定制
Stars: ✭ 113 (+105.45%)
Mutual labels:  compression, gzip
Sharpcompress
SharpCompress is a fully managed C# library to deal with many compression types and formats.
Stars: ✭ 1,397 (+2440%)
Mutual labels:  compression, gzip
Bit7z
A C++ static library offering a clean and simple interface to the 7-zip DLLs.
Stars: ✭ 159 (+189.09%)
Mutual labels:  compression, gzip
Denoflate
WebAssembly powered Deflate/Gzip/Zlib compression for Deno, written in Rust
Stars: ✭ 80 (+45.45%)
Mutual labels:  compression, gzip
Zippy
Pure Nim implementation of deflate, zlib, gzip and zip.
Stars: ✭ 88 (+60%)
Mutual labels:  compression, gzip
Tinydeflate
A deflate/gzip decompressor that requires minimal amount of memory to work
Stars: ✭ 148 (+169.09%)
Mutual labels:  compression, gzip
Compress
Optimized Go Compression Packages
Stars: ✭ 2,478 (+4405.45%)
Mutual labels:  compression, 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 (+247.27%)
Mutual labels:  compression, gzip
Turbobench
Compression Benchmark
Stars: ✭ 211 (+283.64%)
Mutual labels:  compression, gzip
Compression
Node.js compression middleware
Stars: ✭ 2,506 (+4456.36%)
Mutual labels:  compression, gzip
Genozip
Compressor for genomic files (FASTQ, SAM/BAM, VCF, FASTA, GVF, 23andMe...), up to 5x better than gzip and faster too
Stars: ✭ 53 (-3.64%)
Mutual labels:  compression, gzip
Leanify
lightweight lossless file minifier/optimizer
Stars: ✭ 694 (+1161.82%)
Mutual labels:  compression, gzip
Fastify Compress
Fastify compression utils
Stars: ✭ 95 (+72.73%)
Mutual labels:  compression, gzip
Zoonavigator
Web-based ZooKeeper UI / editor / browser
Stars: ✭ 326 (+492.73%)
Mutual labels:  compression, gzip
gzipped
Replacement for golang http.FileServer which supports precompressed static assets.
Stars: ✭ 86 (+56.36%)
Mutual labels:  compression, gzip
EasyCompressor
⚡ A compression library that implements many compression algorithms such as LZ4, Zstd, LZMA, Snappy, Brotli, GZip, and Deflate. It helps you to improve performance by reducing Memory Usage and Network Traffic for caching.
Stars: ✭ 167 (+203.64%)
Mutual labels:  compression, gzip
lambda-smush-py
Gain additional code space via cheeky compression for Python AWS Lambda functions defined in-line to CloudFormation templates.
Stars: ✭ 17 (-69.09%)
Mutual labels:  compression, 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 (+205.45%)
Mutual labels:  compression, gzip
em inflate
Fast, small, in-memory inflate (zlib, deflate and gzip decompression)
Stars: ✭ 59 (+7.27%)
Mutual labels:  compression, gzip

Hasmin - A Haskell CSS Minifier

Build Status Hackage Hackage-Deps License

Aside from the usual techniques (e.g. whitespace removal, color minification, etc.), the idea was to explore new possibilities, by implementing things other minifiers weren't doing, or they were, but not taking full advantage of.

Also, the minifier implements some techniques that do nothing for minified sizes, but attempt to improve post-compression sizes (at least when using DEFLATE, i.e. gzip).

For a list of techniques, see the wiki. To use it as a library, see below.

Building & Installing

Stack

The easiest and prefered way is using stack. To directly install, use the following one-liner:

git clone [email protected]:contivero/hasmin.git && cd hasmin && stack install

Stack installs inside ~/.local/bin by default. If you'd rather just try hasmin out, replace install by build, and then use stack exec hasmin from inside the hasmin directory (keep in mind it has a slight additional delay at the beginning when run this way).

Cabal

Alternatively, you can use cabal:

$ cd path/to/hasmin/repo
$ cabal update                      # Make sure to have the latest package list
$ cabal sandbox init                # Initialise a sandbox
$ cabal install --only-dependencies # Install dependencies into the sandbox
$ cabal build                       # Build hasmin inside the sandbox

Minifier Usage

Hasmin expects a path to the CSS file, and outputs the minified result to stdout. Say you have a sheet.css and want to minify it, and save it as sheet.min.css. Then, run:

$ hasmin sheet.css > sheet.min.css

Every technique is enabled by default, except for:

  1. Escaped character conversions (e.g. converting \2714 into , enabled with --convert-escaped-characters).
  2. Dimension minifications (e.g. converting 12px to 9pt, enabled with --dimension-min, or just -d).
  3. Lexicographical sorting of declarations (enabled with --sort-declarations).

The first two are disabled mainly because they are—on average, not always—detrimental for DEFLATE compression. As for declaration sorting, whether it benefits or hurts compression rates is very stylesheet-dependent, and the current implementation is quite naive, hence unsafe.

When something needs to be disabled, use the appropriate flag. Not every technique can be toggled, but if there is any one in particular that you need to and can't, open an issue about it.

Note: there is a problem in Windows when using the --convert-escaped-characters flag to enable the conversion of escaped characters. A workaround is changing the code page, which can be done by running chcp 65001 in the terminal (whether cmd, or cygwin).

Library

The preferable way to use Hasmin as a library is to import Hasmin; a usage example can be seen in the module's documentation. That is currently the only module that is sure to abide by PVP. Most other exposed modules are so because tests need it, and thus definitions there may be changed anytime. In case something internal is needed though, feel free to open an issue about it.

Zopfli Integration

Hasmin uses bindings to Google's Zopfli library, allowing the possibility to compress the result.

Since the output is a gzip file, it can be used for the web. It tipically produces files 3~8% smaller than zlib, at the cost of being around 80 times slower, so it is only a good idea if you don't need compression on the fly.

Zopfli is released under the Apache License, Version 2.0.

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].