First of all, the good news: template size is one of the (many) problems we are fixing in Glimmer 2. Based on my quick test, the original template in “Conditional Blocks are Expensive” is 83% smaller in Glimmer 2 — 643 bytes compared to 3.8 KiB in the post.

The proposed change to hoist the block would only save you 21 bytes, or 12 bytes after gzip:

(Gzip works a bit differently when applied to the entire bundle, but this is probably a good enough estimate for our purpose.)

Personally, I think that level of savings (in Glimmer 2) is not worth the maintainability and readability cost, but hyper-optimizing for the current shortcomings could backfire and cost more than just that.

In Glimmer 2, child blocks are lazily compiled at runtime, so the unused blocks are effectively free (you only pay the cost when you eventually enter them). Hoisting the conditionals forces the work to be eager — not just compilation cost but also appending unused DOM, more work for the browser, more things to update and teardown, etc.

Even without Glimmer 2, the laziness aspect is still somewhat true for the current-generation engine: you are inherently trading file size with runtime performance.

Would you be able to test your app on 2.9 alpha and give us some feedback?