Skip to content

Conversation

@cossssmin
Copy link
Collaborator

@cossssmin cossssmin commented Oct 30, 2025

This PR adds a new option, removeInlinedSelectors, which will make Juice remove CSS selectors that it has (possibly) inlined from your CSS input. By default, this option is set to false.

This option only works when removeStyleTags is set to false.

Consider the following example:

const html = `
	<style>
		div { color: red; } 
		.test { background: blue; } 
		@media (max-width: 600px) { 
			div { color: green; } 
		}
	</style>

	<div class="test">Hello</div>`

const result = juice(html, {
	removeStyleTags: false, 
	removeInlinedSelectors: true,
})

The result will be:

<style>
	@media (max-width: 600px) { 
		div { color: green; } 
	}
</style>

<div class="test" style="color: red; background: blue">Hello</div>

@cossssmin cossssmin merged commit a0ed51e 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.

2 participants