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

Spacebars compiler optimisations #319

Conversation

nathan-muir
Copy link
Contributor

Hi, (@filipenevola reopening #279)

Found a few instances where the spacebars compiler aborts optimisations unnecessarily.

Case 1: Inside Block tags, eg {{#if }} ... {{else}} ... {{/if}}
Case 2: More than one level of nested elements. (Compacting HTML.Raw fails)
Case 3: Inside <tables> (caused by a pessimistic workaround to auto-injection of <tbody> when using innerHTML.)

The resolution for Case 1 turned out messier than I had hoped. Due to block tags like {{#markdown}} that don't contain HTML. Rather than exposing the textMode prop, maybe something like isHTML?


My motivation for digging through this code, is to implement a <template whitespace="strip"> mode [1]. Which would work similar to react (Strip any whitespace that contains a newline).

Early comparisons show that this saves around ~100kb (uncompressed) from my client bundle.

[1] 3stack-software@e779b79

@nathan-muir
Copy link
Contributor Author

@filipenevola Seems to be an error with CircleCI configuration?

@filipenevola
Copy link
Collaborator

Yes @nathan-muir, they were using CircleCI 1.0 which was deprecated.

You can see new tests being created here
#317

@filipenevola
Copy link
Collaborator

Hi, tests are fixed on master. Please update your branch.

As HTML.TransformingVisitor would not visit the elements within
each block tag, the OptimisingVisitor would skip a portion of
the templates.
Resolves an issue where RawCompactingVisitor would not
recurse through any nested elements.
Currently all optimisation within tables is avoided. Even
for nested elements.
This prevents optimisation of <table> and <tr> elements,
but allows all children of those elements to be optimised.
@nathan-muir nathan-muir force-pushed the spacebars-compiler-optimisations branch from dd31a69 to 940c73e Compare March 18, 2021 20:53
@filipenevola filipenevola changed the base branch from master to release-2.4 March 19, 2021 20:31
@filipenevola filipenevola merged commit 735f525 into meteor:release-2.4 Mar 19, 2021
@nathan-muir nathan-muir mentioned this pull request Mar 23, 2021
@filipenevola filipenevola added this to the 2.4 milestone Mar 24, 2021
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

Successfully merging this pull request may close these issues.

2 participants