Note that there are some explanatory texts on larger screens.

plurals
  1. POWhy does less directives/more html take longer to compile than more directives/less html?
    primarykey
    data
    text
    <p>In our app, we have several layers of nested directives. In an attempt to speed up the digest cycle, we removed some top level directives that have data-bindings to static data. Instead, we just generated the html from the static data, and compiled that. However, after doing that, we started getting unresponsive script warnings in Firefox. The compile time on this generated html was taking too long.</p> <p>I'm hoping to gain a better understanding of the compile process in these 2 different scenarios so that we can optimize correctly in the future. <a href="http://jsfiddle.net/dnc253/uhJY9/" rel="nofollow">Here is a very simplified fiddle</a> that shows the problem. Here is the important part of it:</p> <pre><code>var repeaterHtml = '&lt;div repeater="allData"&gt;&lt;/div&gt;'; var staticHtml = ''; angular.forEach($scope.allData, function(currData, currIndex) { staticHtml += '&lt;div dir1="allData[' + currIndex + ']"&gt;&lt;/div&gt;'; }); $element.append(staticHtml); </code></pre> <p>When using the <code>staticHtml</code> it takes significantly longer to compile than when just using the <code>repeater</code> directive. Why is this? Is it purely because there is more html to go through? As angular compiles the <code>repeater</code> directive does it not have to do the same compiling as I was doing manually? When the final DOM is exactly the same, what is it about the <code>repeater</code> directive that makes it compile so much faster?</p> <p>I'd appreciate any insight into this. Thanks.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload