Hi, first of all, I wanted to say a huge thank you for creating and maintaining @minify-selectors. It is an amazing tool!
I am opening this issue because I've hit a minor bottleneck with how HTML IDs are handled, and I believe adding a specific option for this would benefit other users as well.
Description of the Feature
I would like to request a feature or a new CLI flag to completely disable the minification of HTML IDs (id="..." and #id selectors) while keeping the excellent CSS class minification fully functional.
Use Case & Motivation
Our website uses anchor links (hash links) for internal navigation within a single page (e.g., <a href="#services"> jumping to <section id="services">).
When @minify-selectors runs, it minifies these IDs into short tokens (e.g., #f). While this works from a purely technical standpoint, it creates two drawbacks for websites:
- UX and Sharing: It is not possible to send or share a meaningful URL with a specific section hash in it. Instead of a clean link, users copy and see a cryptic hash at the end of the URL in their address bar.
- SEO Impact: While search engines primarily index the main URL, having human-readable anchor IDs in shared links and within the document structure provides semantic value and context, which is lost after minification.
Currently, the only way to avoid this is to manually prefix every single ID with __ignore--, which is highly impractical for larger projects.
Proposed Solutions
I can see two potential ways to implement this in the CLI binary:
Option A: A dedicated disable flag
Introduce a new CLI flag, for example --disable-ids or --skip-ids. When provided, the binary will completely ignore standard HTML id attributes and CSS ID selectors (#).
Option B: Allow overriding the default ID attribute
Currently, --custom-id-attribute only adds additional attributes to watch, but still processes the standard id. If --custom-id-attribute could override the default behavior (or if we could pass a flag to tell the parser not to look for the standard id attribute), we could point it to a non-existent attribute to effectively bypass ID minification.
Thank you again for your hard work on this package. Having a way to preserve meaningful IDs in URL hashes would make it perfect.
Hi, first of all, I wanted to say a huge thank you for creating and maintaining
@minify-selectors. It is an amazing tool!I am opening this issue because I've hit a minor bottleneck with how HTML IDs are handled, and I believe adding a specific option for this would benefit other users as well.
Description of the Feature
I would like to request a feature or a new CLI flag to completely disable the minification of HTML IDs (
id="..."and#idselectors) while keeping the excellent CSS class minification fully functional.Use Case & Motivation
Our website uses anchor links (hash links) for internal navigation within a single page (e.g.,
<a href="#services">jumping to<section id="services">).When
@minify-selectorsruns, it minifies these IDs into short tokens (e.g.,#f). While this works from a purely technical standpoint, it creates two drawbacks for websites:Currently, the only way to avoid this is to manually prefix every single ID with
__ignore--, which is highly impractical for larger projects.Proposed Solutions
I can see two potential ways to implement this in the CLI binary:
Option A: A dedicated disable flag
Introduce a new CLI flag, for example
--disable-idsor--skip-ids. When provided, the binary will completely ignore standard HTMLidattributes and CSS ID selectors (#).Option B: Allow overriding the default ID attribute
Currently,
--custom-id-attributeonly adds additional attributes to watch, but still processes the standardid. If--custom-id-attributecould override the default behavior (or if we could pass a flag to tell the parser not to look for the standardidattribute), we could point it to a non-existent attribute to effectively bypass ID minification.Thank you again for your hard work on this package. Having a way to preserve meaningful IDs in URL hashes would make it perfect.