Skip to content

Conversation

@cossssmin
Copy link
Collaborator

This PR adds support for using special CSS comments to skip inlining rules or declarations, and even entire files/style blocks.

Closes #387.

Ignore entire file

Add a /* juice ignore */ comment on the first line in your CSS to skip inlining the entire file or style block:

/* juice ignore */
body { color: red; }
.test { color: blue; }

Ignore next rule

Add /* juice ignore next */ before any CSS rule to skip inlining that rule:

body { color: black; }

/* juice ignore next */
h1 {
  color: blue;
}

p { color: green; }

The h1 rule will not be inlined, but will be preserved when removeStyleTags: true. The body and p rules will be inlined normally.

Ignore next declaration

Add /* juice ignore next */ inside a CSS rule to skip inlining the next declaration:

.test {
  color: red;
  /* juice ignore next */
  font-weight: bold;
  font-size: 14px;
}

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.

Ignore blocks of code

Use start/end comment pairs to ignore multiple rules:

h1 {
  color: black;
}

/* juice start ignore */
h2 {
  color: pink;
}

h3 {
  color: lightcoral;
}
/* juice end ignore */

h4 {
  color: green;
}

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.

@cossssmin cossssmin merged commit 2aef3f7 into master Oct 31, 2025
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEAT] Syntax for ignoring CSS code blocks

2 participants