#77 Optimize Ember Templates

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:

<p class=”instructions1">{{instructionsOne}}</p>
{{#if instructionsTwo}}
<p class=”instructions2">{{instructionsTwo}}</p>

like this:

<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!!!

Originally published at Ember Daily Tips.