Google News
logo
Ember.js - Interview Questions
Why is the run loop useful Ember.js?
Very often, batching similar work has benefits. Web browsers do something quite similar by batching changes to the DOM.
 
Consider the following HTML snippet :
<div id="foo"></div>
<div id="bar"></div>
<div id="baz"></div>
 
and executing the following code :
foo.style.height = '500px' // write
foo.offsetHeight // read (recalculate style, layout, expensive!)

bar.style.height = '400px' // write
bar.offsetHeight // read (recalculate style, layout, expensive!)

baz.style.height = '200px' // write
baz.offsetHeight // read (recalculate style, layout, expensive!)
Advertisement