What happened?
There is no way to opt-out of attribute normalization.
The problem is that transforming class=" xyz " to class="xyz" can lead to React hydration errors, and the minifier does not give us any escape hatch option to turn this normalization off.
Of course, it's better to not have such useless whitespace in the markup in the first place, but sometimes that extra whitespace comes from a third-party npm package and you can't easily fix it in userland.
Here's an example I encountered on the Docusaurus website:

Note that @swc/html minifier has such an option already: normalizeAttributes: false,
Version
7.2.0
What browsers are you seeing the problem on?
No response
Link to reproduce
No response
Relevant log output
No response
Willing to submit a PR?
None
What happened?
There is no way to opt-out of attribute normalization.
The problem is that transforming
class=" xyz "toclass="xyz"can lead to React hydration errors, and the minifier does not give us any escape hatch option to turn this normalization off.Of course, it's better to not have such useless whitespace in the markup in the first place, but sometimes that extra whitespace comes from a third-party npm package and you can't easily fix it in userland.
Here's an example I encountered on the Docusaurus website:
Note that
@swc/htmlminifier has such an option already:normalizeAttributes: false,Version
7.2.0
What browsers are you seeing the problem on?
No response
Link to reproduce
No response
Relevant log output
No response
Willing to submit a PR?
None