css_inline 0.17.0 → 0.19.0

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.
data/README.md CHANGED
@@ -136,11 +136,13 @@ inliner.inline("...")
136
136
  - `keep_style_tags`. Specifies whether to keep "style" tags after inlining. Default: `false`
137
137
  - `keep_link_tags`. Specifies whether to keep "link" tags after inlining. Default: `false`
138
138
  - `keep_at_rules`. Specifies whether to keep "at-rules" (starting with `@`) after inlining. Default: `false`
139
+ - `minify_css`. Specifies whether to remove trailing semicolons and spaces between properties and values. Default: `false`
139
140
  - `base_url`. The base URL used to resolve relative URLs. If you'd like to load stylesheets from your filesystem, use the `file://` scheme. Default: `nil`
140
141
  - `load_remote_stylesheets`. Specifies whether remote stylesheets should be loaded. Default: `true`
141
142
  - `cache`. Specifies caching options for external stylesheets (for example, `StylesheetCache(size: 5)`). Default: `nil`
142
143
  - `extra_css`. Extra CSS to be inlined. Default: `nil`
143
144
  - `preallocate_node_capacity`. **Advanced**. Preallocates capacity for HTML nodes during parsing. This can improve performance when you have an estimate of the number of nodes in your HTML document. Default: `32`
145
+ - `remove_inlined_selectors`. Specifies whether to remove selectors that were successfully inlined from `<style>` blocks. Default: `false`
144
146
 
145
147
  You can also skip CSS inlining for an HTML tag by adding the `data-css-inline="ignore"` attribute to it:
146
148
 
@@ -195,6 +197,19 @@ Such tags will be kept in the resulting HTML even if the `keep_style_tags` optio
195
197
  </body>
196
198
  ```
197
199
 
200
+ If you set the the `minify_css` option to `true`, the inlined styles will be minified by removing trailing semicolons
201
+ and spaces between properties and values.
202
+
203
+ ```html
204
+ <head>
205
+ <!-- With minify_css=true, the <h1> will have `style="color:blue;font-weight:bold"` -->
206
+ <style>h1 { color: blue; font-weight: bold; }</style>
207
+ </head>
208
+ <body>
209
+ <h1>Big Text</h1>
210
+ </body>
211
+ ```
212
+
198
213
  If you'd like to load stylesheets from your filesystem, use the `file://` scheme:
199
214
 
200
215
  ```ruby
@@ -225,15 +240,15 @@ Performance benchmarks show 50-100x faster execution than `roadie` and `premaile
225
240
 
226
241
  The table below shows benchmark results comparing `css_inline`, `roadie`, and `premailer` on typical HTML documents:
227
242
 
228
- | | Size | `css_inline 0.15.0` | `roadie 5.2.1` | `premailer 1.21.0` |
229
- |-------------------|---------|---------------------|----------------|---------------------------|
230
- | Basic usage | 230 B | 6.11 µs | 175.21 µs (**28.75**) | 350.10 µs (**57.24x**) |
231
- | Realistic email 1 | 8.58 KB | 101.82 µs | 721.18 µs (**6.96x**) | 7.99 ms (**78.49x**) |
232
- | Realistic email 2 | 4.3 KB | 77.22 µs | 2.02 ms (**28.48x**) | ERROR |
233
- | GitHub Page | 1.81 MB | 172.41 ms | 8.84 s (**52.21x**) | 2.77 s (**15.97x**) |
243
+ | | Size | `css_inline 0.19.0` | `roadie 5.2.1` | `premailer 1.21.0` |
244
+ |-------------------|---------|---------------------|-------------------------|-------------------------|
245
+ | Basic usage | 230 B | 6.07 µs | 173.50 µs (**28.60x**) | 345.30 µs (**56.91x**) |
246
+ | Realistic email 1 | 8.58 KB | 91.23 µs | 713.40 µs (**7.82x**) | 6.80 ms (**74.53x**) |
247
+ | Realistic email 2 | 4.3 KB | 57.56 µs | 1.99 ms (**34.56x**) | ERROR |
248
+ | GitHub Page | 1.81 MB | 39.15 ms | 8.20 s (**208.62x**) | 2.40 s (**61.29x**) |
234
249
 
235
250
  Please refer to the `test/bench.rb` file to review the benchmark code.
236
- The results displayed above were measured using stable `rustc 1.87` on Ruby `3.3.5`.
251
+ The results displayed above were measured using stable `rustc 1.91` on Ruby `3.4.7`.
237
252
 
238
253
  ## Further reading
239
254