-
Notifications
You must be signed in to change notification settings - Fork 71
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
Improve minification #10
Comments
You don't just want minify-template-strings (i.e. just removing whitespace), you want minify-css-in-template-strings. I don't know of an existing tool that does this. Some other ideas to reduce minified bundle size: #11 |
Is this necessary? :host([hidden]) {
display: none;
} I thought this was the default but am likely missing something. |
Another thing that jumps out is Although this likely wouldn't reduce the gzip/brotli size, it would reduce the number of bytes that need to be parsed and compiled. |
Yes, it's a best practice. |
Eagerly awaiting CSS modules that will make this so much better. |
We could hack something together ourselves. The template literal's contents would be stored in a separate source file in the repository, and processed by a custom script that strips whitespace and applies some simple CSS optimizations. The result would then be injected as a template literal into the built Happy to prototype this if this doesn't sound too horrible to you. |
Sure, but at this point you'd build a build system. I really preferred if we instead chimed in on making CSS Modules a thing rather sooner than later. If you could review their proposal and comment on it, this would be a better use of your brain in my opinion. |
Great idea, thanks. Could you add this to your PR? You can test the changes by running |
Tried it, but turns out not to save anything: #11 (comment) So didn't add it to the PR. Thanks for the pointer, I have been testing the changes! |
Also added the instructions to the README. |
Closed via #11. 🎉 |
The minification of template strings with terser currently is suboptimal, the problem being strings with repeated spaces and line breaks ending up in the minified code (excerpt):
This is most probably me holding terser wrong. Essentially I'm looking for something like babel-plugin-minify-template-strings, but for terser. Help wanted.
CC: @RReverser @mathiasbynens
The text was updated successfully, but these errors were encountered: