Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between incremental DOM and virtual DOM in Angular

I have two questions regarding angular. I've tried reading some articles but I can't get the idea, What is incremental DOM? what is the difference between incremental DOM and virtual DOM?

like image 997
Hiras Haris Avatar asked Dec 16 '19 08:12

Hiras Haris


People also ask

Is there a virtual DOM in angular?

Angular doesn't have Virtual DOM, it uses its own mechanism for Change Detection combined with Zones, which helps Angular going through the Change Detection tree from its root to its leaves.

What is the difference between virtual DOM and Shadow DOM?

In short, the shadow DOM is a browser technology whose main objective is to provide encapsulation when creating elements. On the other hand, the virtual DOM is managed by JavaScript libraries—e.g., React—and it's mostly a strategy to optimize performance.

Does angular use Shadow DOM or virtual DOM?

React and Vue are using Virtual DOM and Angular use direct DOM rendering system.

What type of DOM is used in angular?

AngularJS has directives for binding application data to the attributes of HTML DOM elements.


1 Answers

Incremental DOM is a library for building up DOM trees and updating them in-place when data changes. It differs from the established virtual DOM approach in that no intermediate tree is created (the existing tree is mutated in-place). This approach significantly reduces memory allocation and GC thrashing for incremental updates to the DOM tree therefore increasing performance significantly in some cases.

https://github.com/google/incremental-dom

Virtual DOM compares (diff) a new entire virtual DOM with the previous virtual DOM for changes then applies those changes to the actual DOM. - This approach creates a new virtual DOM to determine the changes (memory heavy).

Incremental DOM has one virtual DOM and walks along the tree to find changes then mutates the virtual DOM and then apply those changes to the actual DOM - (reduced memory size and garbage collection).

Virtual DOM - has a big memory footprint because it needs headroom for changes that "might" happen to the virtual DOM.

Incremental DOM - doesn’t need such a big footprint as memory is only allocated for changes.

Tests have shown that Incremental DOM is fast enough to work even without a virtual DOM also.

like image 107
Edward Newsome Avatar answered Sep 30 '22 00:09

Edward Newsome