What is Virtual DOM?
There are two ways in which a library can find out what has changed:
- Dirty Check
In dirty checking method, all the nodes are checked at regular interval to see if something has changed. This makes it a very slow process. Whereas in “observable” method, components simply listen to state changes and decide when to re-render the UI.
So what is the real advantage of having a Virtual DOM?
React framework uses Virtual DOM heavily. It maintains a copy of real DOM in memory referred as virtual DOM. All the changes are first done to virtual DOM. Later it uses a technique called “diffing” to find out the exact changes to be made to the real DOM. Only this “diff” is then applied to real DOM thereby minimizing the overhead of finding out changes iteratively.
ReactJS, AngularJS, DOM