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

[Optimisation] Don't add whitespace nodes to elements #414

Closed
jacobp100 opened this issue Mar 28, 2017 · 2 comments
Closed

[Optimisation] Don't add whitespace nodes to elements #414

jacobp100 opened this issue Mar 28, 2017 · 2 comments

Comments

@jacobp100
Copy link

When compiling, I see a lot of appendNode( createText( "\n " ), tbody$1 );. On some elements, like pre, this is important. On others, like trs, it's not. It would be great if we could add an optimisation to omit whitespace nodes.

@jacobp100
Copy link
Author

Just a quick experiment reduced my app from 3.89KB (min+gz) to 3.73KB—that's about 5%!

@Rich-Harris
Copy link
Member

Agree — there are definitely some cases where this could be done better. Unfortunately there are others that are less clear-cut — for example, whitespace between elements becomes significant if those elements have a display: inline-block style. (In those cases, the whitespace could be collapsed down to a single character, and thus a shared helper function which would compress better, but then you have to hope that they're not white-space: pre for some reason.) There's no way to know at compile time which styles will apply, so you could easily break people's expectations if you were too aggressive. It could be an option though.

I'm going to close this as there's already a discussion underway at #189.

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

2 participants