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

Ideas for minifiers #12

Open
maltsev opened this issue Feb 5, 2016 · 12 comments
Open

Ideas for minifiers #12

maltsev opened this issue Feb 5, 2016 · 12 comments

Comments

@maltsev
Copy link
Member

maltsev commented Feb 5, 2016

@voischev
Copy link
Member

voischev commented Feb 6, 2016

remove \n \t and ect

tree.match(/^\n\s*$/, () => '');

https://github.com/posthtml/project-stub/blob/master/gulpfile.js#L14-L18

@maltsev
Copy link
Member Author

maltsev commented Feb 6, 2016

@voischev the module collapseWhitespace does that. Or did you find some error?

@stevenvachon
Copy link

The biggest thing for me is to split out to separate plugins for individual test suites:

  • posthtml-normalize-whitespace
  • posthtml-remove-attrs
  • posthtml-merge-styles
  • posthtml-merge-scripts
  • posthtml-cssnano
  • posthtml-uglifyjs
  • posthtml-collapse-json (for JSON-LD SEO schemas, particularly)
  • etc

@maltsev normalize-html-whitespace is the most accurate. @voischev, the key is to normalize, not strip as to preserve rendered appearance.

@maltsev
Copy link
Member Author

maltsev commented Feb 10, 2016

@stevenvachon, first of all, thank you for new plugin ideas! I'll consider splitting out the modules to separate plugins. But it'll be much harder for me to maintain a few dozens small plugins (documentation, infrastructure) instead of one htmlnano.

@maltsev maltsev changed the title Minifiers [ideas] Ideas for minifiers Feb 10, 2016
@stevenvachon
Copy link

No problem. It's definitely more work to create separate projects, at least initially. Once created, it will make dealing with tests much easier because there're fewer of them and they're all very specific to one feature. This is how cssnano and cssnext are designed.

@maltsev
Copy link
Member Author

maltsev commented Feb 10, 2016

@stevenvachon, I agree with you. I'm also trying to write the modules and the tests as separated as possible, so it'll be easy to split off them later.

@stevenvachon
Copy link

Whitespace within attributes containing space-separated lists can also be normalized:

<a href="#" class="class1   class2 " rel=" external    nofollow ">link</a>

->

<a href="#" class="class1 class2" rel="external nofollow">link</a>

@stevenvachon
Copy link

  1. switch between ' and " (per attribute) as attribute value encapsulators to find which produces the smallest output (due to any necessary commenting: attr='blah \'blah\'' vs attr="blah 'blah'")
  2. remove quotes on qualifying attributes (attr=single_value)

@maltsev
Copy link
Member Author

maltsev commented Mar 3, 2016

@stevenvachon, thanks! I've created an issue for your first idea: #27
An issue for the second one is already there: #6

@stevenvachon
Copy link

svgo for inline svg

@stevenvachon
Copy link

  1. Remove optional closing tags such as </html>, </head>, </body>, </option>, </p>, </thead>, </tbody>, </tfoot>, </tr>
  2. remove optional opening tags such as <html>, <head>, <body>

@stevenvachon
Copy link

Strip HTML from content within <title></title> tags as browsers and search engines will ignore it anyway.

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