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

Minify CSS class names and ids #69

Open
fstanis opened this issue Dec 27, 2018 · 6 comments
Open

Minify CSS class names and ids #69

fstanis opened this issue Dec 27, 2018 · 6 comments

Comments

@fstanis
Copy link
Contributor

fstanis commented Dec 27, 2018

This can be done simply by calling posthtml-uglify inside minifyCss.

Bonus is that it can share the whitelist with uncss if we add uncss per #36.

@maltsev
Copy link
Member

maltsev commented Dec 27, 2018

Good idea! I guess it might break some pages, so it's better to add it to max preset.

Does posthtml-uglify take into account external styles? If not then we should do that on our side.

@fstanis
Copy link
Contributor Author

fstanis commented Dec 28, 2018

Does posthtml-uglify take into account external styles?

No, it only looks at <style> tags.

If not then we should do that on our side.

How would that work? Wouldn't that mean that htmlnano would have to modify files outside the HTML?

@maltsev
Copy link
Member

maltsev commented Dec 31, 2018

How would that work?

I see a few possible ways:

  • Ignore classes and IDs found in external CSS. Not sure how easy it'd be to parse them, though.
  • Rewrite names in external CSS. It seems a bit out of htmlnano's scope for me, though.
  • Disable minification at all if external CSS is found.

In an ideal case, we could implement all 3 options and let users configure that themselves how they want this minification work.

@fstanis
Copy link
Contributor Author

fstanis commented Jan 3, 2019

Ouch, completely forgot that this will break external stylesheets. That's a tricky problem to solve.

Disable minification at all if external CSS is found.

This seems like a good low-hanging fruit for a first version.

I'm also worried that posthtml-uglify seems unmaintained (at least based on PR / issue activity). Taking this into account, I'm now leaning more towards replicating similar functionality in htmlnano (or maybe forking the project?).

@maltsev
Copy link
Member

maltsev commented Jan 3, 2019

I'm also worried that posthtml-uglify seems unmaintained (at least based on PR / issue activity).

I think it's totally fine to use it. We can always switch htmlnano to a forked version if needed. We could also ask then if @Rebelmail are willing to transfer posthtml-uglify to posthtml namespace.

@polarathene
Copy link

You may also want to consider posthtml-minify-classnames which still receives maintenance and has a few more improvements over posthtml-uglify?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants