minify_html 0.2.5 → 0.3.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +41 -46
- data/lib/linux-ruby2.5 +0 -0
- data/lib/linux-ruby2.6 +0 -0
- data/lib/linux-ruby2.7 +0 -0
- data/lib/macos-ruby2.5 +0 -0
- data/lib/macos-ruby2.6 +0 -0
- data/lib/macos-ruby2.7 +0 -0
- metadata +3 -3
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA256:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: b00d960a09c6d4de6681e685eb99b36d696cb8858b18a0654fabedf80b382a69
         | 
| 4 | 
            +
              data.tar.gz: bcc1185949fccb475dcc7635a9426d54b4f7edff5cb3a27cae824c6da456dc68
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: aa9f76653e9059242cb57d4dba063c108ea9d710d465b1196f21e578c7a6c2b321b8c23fa9fc068eee5f3a9710be069bbe3d2722040469dcda49a9742a2240dc
         | 
| 7 | 
            +
              data.tar.gz: e600314828a8b2a0f29a4412fbc4cf7e3fcceb4c22b842019f4f638a16e76e5d8fa3da2bb6700cc04e76cf1cd2dceb336500f0bfb324eb73c6384ec1e99e4bca
         | 
    
        data/README.md
    CHANGED
    
    | @@ -1,37 +1,29 @@ | |
| 1 1 | 
             
            # minify-html
         | 
| 2 2 |  | 
| 3 | 
            -
             | 
| 3 | 
            +
            An HTML minifier meticulously optimised for both speed and effectiveness, available for Rust, Node.js, Python, Java, and Ruby.
         | 
| 4 4 |  | 
| 5 | 
            -
             | 
| 6 | 
            -
             | 
| 7 | 
            -
            Available as:
         | 
| 8 | 
            -
            - CLI for macOS and Linux.
         | 
| 9 | 
            -
            - Rust library.
         | 
| 10 | 
            -
            - Native library for Node.js, Python, Java, and Ruby.
         | 
| 11 | 
            -
             | 
| 12 | 
            -
            ## Features
         | 
| 13 | 
            -
             | 
| 14 | 
            -
            - Minification is done in one pass with no backtracking or DOM/AST building.
         | 
| 15 | 
            -
            - No extra heap memory is allocated during processing, which increases performance.
         | 
| 16 | 
            -
            - Context-aware whitespace handling allows maximum minification while retaining desired spaces.
         | 
| 5 | 
            +
            - Advanced minification strategy beats other minifiers with only one pass.
         | 
| 6 | 
            +
            - Uses zero memory allocations, SIMD searching, direct tries, and lookup tables.
         | 
| 17 7 | 
             
            - Well tested with a large test suite and extensive [fuzzing](./fuzz).
         | 
| 8 | 
            +
            - Natively binds to [esbuild](https://github.com/wilsonzlin/esbuild-rs) for super fast JS minification.
         | 
| 18 9 |  | 
| 19 10 | 
             
            ## Performance
         | 
| 20 11 |  | 
| 21 | 
            -
             | 
| 12 | 
            +
            Comparison with [html-minfier](https://github.com/kangax/html-minifier) and [minimize](https://github.com/Swaagie/minimize), run on the top web pages. [See the breakdown here.](./bench)
         | 
| 22 13 |  | 
| 23 | 
            -
            <img width=" | 
| 14 | 
            +
            <img width="415" alt="Chart showing speed of HTML minifiers" src="https://wilsonl.in/minify-html/bench/0.3.3/js/average-speeds.png"> <img width="415" alt="Chart showing effectiveness of HTML minifiers" src="https://wilsonl.in/minify-html/bench/0.3.3/js/average-sizes.png">
         | 
| 24 15 |  | 
| 25 16 | 
             
            ## Usage
         | 
| 26 17 |  | 
| 27 18 | 
             
            ### CLI
         | 
| 28 19 |  | 
| 29 | 
            -
            Precompiled binaries are available for x86-64 macOS and  | 
| 20 | 
            +
            Precompiled binaries are available for x86-64 Linux, macOS, and Windows.
         | 
| 30 21 |  | 
| 31 22 | 
             
            ##### Get
         | 
| 32 23 |  | 
| 33 | 
            -
            [ | 
| 34 | 
            -
            [ | 
| 24 | 
            +
            [Linux](https://wilsonl.in/minify-html/bin/0.3.3-linux-x86_64) |
         | 
| 25 | 
            +
            [macOS](https://wilsonl.in/minify-html/bin/0.3.3-macos-x86_64) |
         | 
| 26 | 
            +
            [Windows](https://wilsonl.in/minify-html/bin/0.3.3-windows-x86_64.exe)
         | 
| 35 27 |  | 
| 36 28 | 
             
            ##### Use
         | 
| 37 29 |  | 
| @@ -50,7 +42,7 @@ minify-html --src /path/to/src.html --out /path/to/output.min.html | |
| 50 42 |  | 
| 51 43 | 
             
            ```toml
         | 
| 52 44 | 
             
            [dependencies]
         | 
| 53 | 
            -
            minify-html = { version = "0. | 
| 45 | 
            +
            minify-html = { version = "0.3.3", features = ["js-esbuild"] }
         | 
| 54 46 | 
             
            ```
         | 
| 55 47 |  | 
| 56 48 | 
             
            Building with the `js-esbuild` feature requires the Go compiler to be installed as well, to build the [JS minifier](https://github.com/evanw/esbuild).
         | 
| @@ -60,7 +52,7 @@ If the `js-esbuild` feature is not enabled, `cfg.minify_js` will have no effect. | |
| 60 52 | 
             
            ##### Use
         | 
| 61 53 |  | 
| 62 54 | 
             
            ```rust
         | 
| 63 | 
            -
            use minify_html::{Cfg, FriendlyError, in_place, copy, with_friendly_error, truncate};
         | 
| 55 | 
            +
            use minify_html::{Cfg, Error, FriendlyError, in_place, copy, with_friendly_error, truncate};
         | 
| 64 56 |  | 
| 65 57 | 
             
            fn main() {
         | 
| 66 58 | 
             
                let mut code = b"<p>  Hello, world!  </p>".to_vec();
         | 
| @@ -72,21 +64,21 @@ fn main() { | |
| 72 64 | 
             
                // but leaves any original code after the minified code intact.
         | 
| 73 65 | 
             
                match in_place(&mut code, cfg) {
         | 
| 74 66 | 
             
                    Ok(minified_len) => {}
         | 
| 75 | 
            -
                    Err( | 
| 67 | 
            +
                    Err(Error { error_type, position }) => {}
         | 
| 76 68 | 
             
                };
         | 
| 77 69 |  | 
| 78 70 | 
             
                // Creates a vector copy containing only minified code
         | 
| 79 71 | 
             
                // instead of minifying in-place.
         | 
| 80 72 | 
             
                match copy(&code, cfg) {
         | 
| 81 73 | 
             
                    Ok(minified) => {}
         | 
| 82 | 
            -
                    Err( | 
| 74 | 
            +
                    Err(Error { error_type, position }) => {}
         | 
| 83 75 | 
             
                };
         | 
| 84 76 |  | 
| 85 77 | 
             
                // Minifies a vector in-place, and then truncates the
         | 
| 86 78 | 
             
                // vector to the new minified length.
         | 
| 87 79 | 
             
                match truncate(&mut code, cfg) {
         | 
| 88 80 | 
             
                    Ok(()) => {}
         | 
| 89 | 
            -
                    Err( | 
| 81 | 
            +
                    Err(Error { error_type, position }) => {}
         | 
| 90 82 | 
             
                };
         | 
| 91 83 |  | 
| 92 84 | 
             
                // Identical to `in_place` except with FriendlyError instead.
         | 
| @@ -108,46 +100,48 @@ fn main() { | |
| 108 100 | 
             
            <details>
         | 
| 109 101 | 
             
            <summary><strong>Node.js</strong></summary>
         | 
| 110 102 |  | 
| 111 | 
            -
            Package: [@minify-html/js | 
| 112 | 
            -
            Binding: [ | 
| 113 | 
            -
            Platforms: macOS,  | 
| 103 | 
            +
            - Package: [@minify-html/js](https://www.npmjs.com/package/@minify-html/js)
         | 
| 104 | 
            +
            - Binding: [N-API](https://nodejs.org/api/n-api.html)
         | 
| 105 | 
            +
            - Platforms: Linux, macOS, Windows; Node.js 8.6.0 and higher
         | 
| 114 106 |  | 
| 115 107 | 
             
            ##### Get
         | 
| 116 108 |  | 
| 117 109 | 
             
            Using npm:
         | 
| 118 110 |  | 
| 119 111 | 
             
            ```bash
         | 
| 120 | 
            -
            npm i @minify-html/js | 
| 112 | 
            +
            npm i @minify-html/js
         | 
| 121 113 | 
             
            ```
         | 
| 122 114 |  | 
| 123 115 | 
             
            Using Yarn:
         | 
| 124 116 |  | 
| 125 117 | 
             
            ```bash
         | 
| 126 | 
            -
            yarn add @minify-html/js | 
| 118 | 
            +
            yarn add @minify-html/js
         | 
| 127 119 | 
             
            ```
         | 
| 128 120 |  | 
| 129 121 | 
             
            ##### Use
         | 
| 130 122 |  | 
| 131 123 | 
             
            ```js
         | 
| 132 | 
            -
            const minifyHtml = require("@minify-html/js | 
| 124 | 
            +
            const minifyHtml = require("@minify-html/js");
         | 
| 133 125 |  | 
| 134 | 
            -
            const cfg = { minifyJs: false };
         | 
| 126 | 
            +
            const cfg = minifyHtml.createConfiguration({ minifyJs: false });
         | 
| 135 127 | 
             
            const minified = minifyHtml.minify("<p>  Hello, world!  </p>", cfg);
         | 
| 136 128 |  | 
| 137 129 | 
             
            // Alternatively, minify in place to avoid copying.
         | 
| 138 | 
            -
            const source = Buffer.from("<p>  Hello, world!  </p>" | 
| 139 | 
            -
             | 
| 130 | 
            +
            const source = Buffer.from("<p>  Hello, world!  </p>");
         | 
| 131 | 
            +
            // This is a Buffer representing a slice of `source`, not newly allocated memory.
         | 
| 132 | 
            +
            const minified = minifyHtml.minifyInPlace(source, cfg);
         | 
| 140 133 | 
             
            ```
         | 
| 141 134 |  | 
| 142 135 | 
             
            minify-html is also available for TypeScript:
         | 
| 143 136 |  | 
| 144 137 | 
             
            ```ts
         | 
| 145 | 
            -
            import * as minifyHtml from "@minify-html/js | 
| 138 | 
            +
            import * as minifyHtml from "@minify-html/js";
         | 
| 146 139 | 
             
            import * as fs from "fs";
         | 
| 147 140 |  | 
| 148 | 
            -
            const cfg = { minifyJs: false };
         | 
| 141 | 
            +
            const cfg = minifyHtml.createConfiguration({ minifyJs: false });
         | 
| 149 142 | 
             
            const minified = minifyHtml.minify("<p>  Hello, world!  </p>", cfg);
         | 
| 150 | 
            -
             | 
| 143 | 
            +
            // Or alternatively:
         | 
| 144 | 
            +
            const minified = minifyHtml.minifyInPlace(fs.readFileSync("source.html"), cfg);
         | 
| 151 145 | 
             
            ```
         | 
| 152 146 |  | 
| 153 147 | 
             
            </details>
         | 
| @@ -155,9 +149,9 @@ minifyHtml.minifyInPlace(fs.readFileSync("source.html"), cfg); | |
| 155 149 | 
             
            <details>
         | 
| 156 150 | 
             
            <summary><strong>Java</strong></summary>
         | 
| 157 151 |  | 
| 158 | 
            -
            Package: [in.wilsonl.minifyhtml](https://search.maven.org/artifact/in.wilsonl.minifyhtml/minify-html)
         | 
| 159 | 
            -
            Binding: [JNI](https://github.com/jni-rs/jni-rs)
         | 
| 160 | 
            -
            Platforms: macOS,  | 
| 152 | 
            +
            - Package: [in.wilsonl.minifyhtml](https://search.maven.org/artifact/in.wilsonl.minifyhtml/minify-html)
         | 
| 153 | 
            +
            - Binding: [JNI](https://github.com/jni-rs/jni-rs)
         | 
| 154 | 
            +
            - Platforms: Linux, macOS, Windows; Java 7 and higher
         | 
| 161 155 |  | 
| 162 156 | 
             
            ##### Get
         | 
| 163 157 |  | 
| @@ -167,14 +161,14 @@ Add as a Maven dependency: | |
| 167 161 | 
             
            <dependency>
         | 
| 168 162 | 
             
              <groupId>in.wilsonl.minifyhtml</groupId>
         | 
| 169 163 | 
             
              <artifactId>minify-html</artifactId>
         | 
| 170 | 
            -
              <version>0. | 
| 164 | 
            +
              <version>0.3.3</version>
         | 
| 171 165 | 
             
            </dependency>
         | 
| 172 166 | 
             
            ```
         | 
| 173 167 |  | 
| 174 168 | 
             
            ##### Use
         | 
| 175 169 |  | 
| 176 170 | 
             
            ```java
         | 
| 177 | 
            -
            import in.wilsonl. | 
| 171 | 
            +
            import in.wilsonl.minifyhtml.MinifyHtml;
         | 
| 178 172 |  | 
| 179 173 | 
             
            MinifyHtml.Configuration cfg = new MinifyHtml.Configuration.Builder()
         | 
| 180 174 | 
             
                .setMinifyJs(false)
         | 
| @@ -195,9 +189,9 @@ MinifyHtml.minifyInPlace(source, cfg); | |
| 195 189 | 
             
            <details>
         | 
| 196 190 | 
             
            <summary><strong>Python</strong></summary>
         | 
| 197 191 |  | 
| 198 | 
            -
            Package: [ | 
| 199 | 
            -
            Binding: [PyO3](https://github.com/PyO3/pyo3)
         | 
| 200 | 
            -
            Platforms: macOS,  | 
| 192 | 
            +
            - Package: [minify-html](https://pypi.org/project/minify-html)
         | 
| 193 | 
            +
            - Binding: [PyO3](https://github.com/PyO3/pyo3)
         | 
| 194 | 
            +
            - Platforms: Linux, macOS, Windows; Python 3.5 and higher
         | 
| 201 195 |  | 
| 202 196 | 
             
            ##### Get
         | 
| 203 197 |  | 
| @@ -219,9 +213,9 @@ except SyntaxError as e: | |
| 219 213 | 
             
            <details>
         | 
| 220 214 | 
             
            <summary><strong>Ruby</strong></summary>
         | 
| 221 215 |  | 
| 222 | 
            -
            Package: [minify_html](https://rubygems.org/gems/minify_html)
         | 
| 223 | 
            -
            Binding: [Rutie](https://github.com/danielpclark/rutie)
         | 
| 224 | 
            -
            Platforms:  | 
| 216 | 
            +
            - Package: [minify_html](https://rubygems.org/gems/minify_html)
         | 
| 217 | 
            +
            - Binding: [Rutie](https://github.com/danielpclark/rutie)
         | 
| 218 | 
            +
            - Platforms: Linux, macOS; Ruby 2.5 and higher
         | 
| 225 219 |  | 
| 226 220 | 
             
            ##### Get
         | 
| 227 221 |  | 
| @@ -455,6 +449,7 @@ Spaces are removed between attributes if possible. | |
| 455 449 | 
             
            ### Entities
         | 
| 456 450 |  | 
| 457 451 | 
             
            Entities are decoded if valid (see relevant parsing section) and their decoded characters as UTF-8 is shorter or equal in length.
         | 
| 452 | 
            +
            Some entities are longer decoded than encoded, so they're left encoded.
         | 
| 458 453 |  | 
| 459 454 | 
             
            Numeric entities that do not refer to a valid [Unicode Scalar Value](https://www.unicode.org/glossary/#unicode_scalar_value) are replaced with the [replacement character](https://en.wikipedia.org/wiki/Specials_(Unicode_block)#Replacement_character).
         | 
| 460 455 |  | 
    
        data/lib/linux-ruby2.5
    CHANGED
    
    | Binary file | 
    
        data/lib/linux-ruby2.6
    CHANGED
    
    | Binary file | 
    
        data/lib/linux-ruby2.7
    CHANGED
    
    | Binary file | 
    
        data/lib/macos-ruby2.5
    CHANGED
    
    | Binary file | 
    
        data/lib/macos-ruby2.6
    CHANGED
    
    | Binary file | 
    
        data/lib/macos-ruby2.7
    CHANGED
    
    | Binary file | 
    
        metadata
    CHANGED
    
    | @@ -1,14 +1,14 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: minify_html
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 0. | 
| 4 | 
            +
              version: 0.3.3
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - Wilson Lin
         | 
| 8 8 | 
             
            autorequire: 
         | 
| 9 9 | 
             
            bindir: bin
         | 
| 10 10 | 
             
            cert_chain: []
         | 
| 11 | 
            -
            date: 2020-07- | 
| 11 | 
            +
            date: 2020-07-27 00:00:00.000000000 Z
         | 
| 12 12 | 
             
            dependencies:
         | 
| 13 13 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 14 14 | 
             
              name: fiddle
         | 
| @@ -62,5 +62,5 @@ rubyforge_project: | |
| 62 62 | 
             
            rubygems_version: 2.7.6.2
         | 
| 63 63 | 
             
            signing_key: 
         | 
| 64 64 | 
             
            specification_version: 4
         | 
| 65 | 
            -
            summary: Fast  | 
| 65 | 
            +
            summary: Fast and smart HTML + JS minifier
         | 
| 66 66 | 
             
            test_files: []
         |