You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+82Lines changed: 82 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -225,6 +225,88 @@ The `data-embed` attribute will be removed from the output HTML, but no inlining
225
225
</style>
226
226
```
227
227
228
+
### Ignoring CSS with comments
229
+
230
+
You can use special CSS comments to prevent Juice from inlining entire CSS files, rules, or even just declarations.
231
+
232
+
#### Ignore entire file
233
+
234
+
Add a `/* juice ignore */` comment on the first line in your CSS:
235
+
236
+
```html
237
+
<style>
238
+
/* juice ignore */
239
+
body { color: red; }
240
+
.test { color: blue; }
241
+
</style>
242
+
243
+
<body>
244
+
<divclass="test">Hello World</div>
245
+
</body>
246
+
```
247
+
248
+
The entire CSS will be ignored (as in, not inlined).
249
+
250
+
With `removeStyleTags: true`, the whole `<style>` tag will be preserved.
251
+
252
+
#### Ignore next rule
253
+
254
+
Add `/* juice ignore next */` before any CSS rule to skip inlining that rule:
255
+
256
+
```css
257
+
body { color: black; }
258
+
259
+
/* juice ignore next */
260
+
h1 {
261
+
color: blue;
262
+
}
263
+
264
+
p { color: green; }
265
+
```
266
+
267
+
The `h1` rule will not be inlined, but will be preserved when `removeStyleTags: true`. The `body` and `p` rules will be inlined normally.
268
+
269
+
#### Ignore next declaration
270
+
271
+
Add `/* juice ignore next */` inside a CSS rule to skip inlining the next declaration:
272
+
273
+
```css
274
+
.test {
275
+
color: red;
276
+
/* juice ignore next */
277
+
font-weight: bold;
278
+
font-size: 14px;
279
+
}
280
+
```
281
+
282
+
The `color` and `font-size` will be inlined, but `font-weight` will not. The rule with the ignored declaration will be preserved in a `<style>` tag when `removeStyleTags: true`.
283
+
284
+
#### Ignore blocks of code
285
+
286
+
Use start/end comment pairs to ignore multiple rules:
287
+
288
+
```css
289
+
h1 {
290
+
color: black;
291
+
}
292
+
293
+
/* juice start ignore */
294
+
h2 {
295
+
color: pink;
296
+
}
297
+
298
+
h3 {
299
+
color: lightcoral;
300
+
}
301
+
/* juice end ignore */
302
+
303
+
h4 {
304
+
color: green;
305
+
}
306
+
```
307
+
308
+
The `h2` and `h3` rules will not be inlined but will be preserved in a `<style>` tag when `removeStyleTags: true`. The `h1` and `h4` rules will be inlined normally.
309
+
228
310
### CLI Options
229
311
230
312
To use Juice from CLI, run `juice [options] input.html output.html`
0 commit comments