

strip superfluous quotes, or uses single/double quotes whichever requires fewer escapes.

strip unnecessary whitespace and otherwise collapse it to one space (or newline if it originally contained a newline).

The HTML5 minifier uses these minifications: HTML (with JS and CSS) minification typically shaves off about 10%. JSON/sample_testsuite.json-4 394MB/s ± 0% HTML/sample_wikipedia.html-4 67.5MB/s ± 0% HTML/sample_stackoverflow.html-4 55.0MB/s ± 0% HTML/sample_blogpost.html-4 49.8MB/s ± 0% HTML/sample_stackoverflow.html-4 3.73ms ± 0%ĬSS/sample_fontawesome.css-4 61.2MB/s ± 0% To give an indication of the speed of this library, I've ran the tests on my Thinkpad T460 (i5-6300U quad-core 2.4GHz running Arch Linux) using Go 1.15. The benchmarks directory contains a number of standardized samples used to compare performance between changes. If you still encounter a bug, please file a bug report! Performance These tests ensure that everything works as intended and that the code does not crash (whatever the input). Besides full coverage, the minifiers are fuzz tested using /dvyukov/go-fuzz, see the wiki for the most important bugs found by fuzz testing. Testingįor all subpackages and the imported parse package, test coverage of 100% is pursued. There are no plans whatsoever for future API changes. There has been one API change after v1 which added options support and I took the opportunity to push through some more API clean up as well. The library will be maintained in a compatible way unless vital bugs prevent me from doing so. There is no guarantee for absolute stability, but I take issues and bugs seriously and don't take API changes lightly. $ docker run -it tdewolff/minify -help API stability Make sure you have Git and Go (1.13 or higher) installed, run

It is usually orders of magnitude faster than existing minifiers. This minifier proves to be that fast and extensive minifier that can handle HTML and any other filetype it may contain (CSS, JS. As most existing implementations either use JavaScript, use regexes, and don't focus on performance, they are pretty slow. Some implementations are much more profound, such as the YUI Compressor and Google Closure Compiler for JS. Some implementations are merely using several regular expressions to trim whitespace and comments (even though regex for parsing HTML/XML is ill-advised, for a good read see Regular Expressions: Now You Have Two Problems). Minifiers or bindings to minifiers exist in almost all programming languages. merging CSS and JS files, inlining small external files, minification and gzipping.
