I have a template (partial) that I use in few parts of my app problem is rendering this template takes a bit 1-3 seconds. I optimized the rendering process as much as I could but it's still a bit slow.
My template:
<div ng-repeat="row in rows track by $index">
<div ng-repeat="col in row track by $index">
<div class="column" ng-click="checkColumn($parent.$index, $index, col)">
<img ng-src="..." ng-if="col.checked" />
<img ng-src="..." ng-if="col.reserved" />
<img ng-src="..." ng-if="col.used" />
<img ng-src="..." ng-if="col.locked" />
<img ng-src="..." ng-if="col.private" />
<img ng-src="..." ng-if="col.disabled" />
<img ng-src="..." ng-if="col.large" />
<img ng-src="..." ng-if="col.small" />
</div>
</div>
</div>
On average there are 15 rows and each row usually has avg. 17 cols. So usually about 255 <div class="column"> get created.
My idea was to when the application is loading before visiting the screen where this is show to get rows from the API than pass them to this template have it render.
Than save rows and rendered template to local storage. Than in rest of my controllers where I need this I can just restore rows from local storage and inject template from local storage.
Just not sure exactly how I would go about this on AngularJS side.
.columnhave more than oneimgdisplayed at once? If not, you could aggregate all thengIfsinto oneimg.ng-if? Mostly, it's used when you need to re-init controller bind to directive etc. I suggest try usingng-showinstead. This will speed up your second rendering (coz it will be not rendering but just showing hidden elements what is much faster)ngIfsinsidengSrcsince it works with Angular expressions. This would give you a performance boost as you'll trim down the number on watchers.