Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CSS Minification: Decline to minify files containing unicode escapes like \f178 #50

Closed
wants to merge 5 commits into from

Conversation

mreishus
Copy link
Contributor

@mreishus mreishus commented Jan 28, 2025

We found a bug that happens when minifying files like WP's dashicons.css.

It uses unicode escapes like so:

.dashicons-sticky:before {
	content: "\f537";
}

.dashicons-store:before {
	content: "\f513";
}

.dashicons-superhero-alt:before {
	content: "\f197";
}

The current engine turns these into unicode codepoints, then renders them in utf-8 bytes. If the browser decides to interpret the file as ASCII, or another non-utf8 encoding, then the user will see 文字化け (mojibake) instead of their icon.

It has been difficult to find an engine that hits all three points of:

  • Supports modern CSS syntax and is actively maintained
  • Does not reencode unicode escape sequences
  • Is performant

While we evaluate other options, this PR changes the behavior to skip minifying files that contain unicode escape sequences. While this gives up some minification benefits, it ensures the user will always see icons as intended.

@mreishus
Copy link
Contributor Author

We probably don't need to do this anymore with #51 also covering this problem

@mreishus
Copy link
Contributor Author

We decided to go with CSSNano + Lite Preset.

@mreishus mreishus closed this Jan 30, 2025
@mreishus mreishus deleted the skip-unicode-escapes branch January 30, 2025 18:24
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.

1 participant