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

Feature Request: Option to pass in an array of attributes to be stripped from the html #86

Open
nCubed opened this issue Sep 24, 2021 · 4 comments

Comments

@nCubed
Copy link

nCubed commented Sep 24, 2021

We have a few attributes we use in dev, but are not needed in prod. Any chance a new setting could be created, allowing an array of attributes to be stripped from the minified html?

@DanielRuf
Copy link
Contributor

What type of attributes exactly do you mean?

html-minifier(-terser) only minifies the code but does not cover such prod / dev differences since this has not much to do with the general minification.

To be honest I never had this use case in more than 11 years.

I guess you have a build setup which uses webpack or something else. So there you can do the needed replacements.

There are already plugins for webpack and babel which do this:

https://www.google.com/search?q=webpack+html+remove+attributes+plugin
https://stackoverflow.com/questions/43934210/remove-html-attribute-in-production-build

@nCubed
Copy link
Author

nCubed commented Sep 25, 2021

We're not using webpack. The attributes are used during language translation; the localized files have the attributes removed, but the original non-localized files keep the attributes. I've put in a request to the package's repository to include the option to strip the attributes from the original files, but the maintainer(s) have not replied.

Was thinking maybe you could piggy-back on the current setting for removeEmptyAttributes and include the option to pass in an array of attributes to remove as well.

Understood this is a weird edge-case. Thought I'd ask :)

@sibiraj-s
Copy link
Collaborator

I am fine in adding that option to do this, but I don't feel like removeEmptyAttributes is the right place even to piggy-back it.

One way for you is to write a script to read the minified file and replace(remove) attributes may be with regex or whatever that works. or we can introduce a new option may be removeAttributes which can take an array of attributes to be removed.

@nCubed
Copy link
Author

nCubed commented Oct 1, 2021

Obviously my preference would be the latter option of removeAttributes 🤩

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

No branches or pull requests

3 participants