I have to admit that it never crossed my mind to optimize my ember app by changing how I create my templates until I read this article.
Here is just one simple example from the article:
If you rewrite:
1 2 3 4 |
<p class=”instructions1">{{instructionsOne}}</p> {{#if instructionsTwo}} <p class=”instructions2">{{instructionsTwo}}</p> {{/if}} |
like this:
1 2 |
<p class=”instructions1">{{instructionsOne}}</p> <p class=”instructions2 {{unless instructionsTwo ‘hide’}}”>{{instructionsTwo}}</p> |
Your app size goes from 3.8kb to 1.2kb – WOW!!! Multiply that by the number of if statements in your templates and you can see the benefit. Pretty cool!!!
Also published on Medium.