I want to know what is main problem between javascript and DOM that Angular / React / Vue try to solve,
Please guide me I'm new learning Angular.
3 Answers
React and Vue use a pattern called the Virtual DOM to optimize updating the DOM in order to render changes faster. Angular uses another method with similar motivations. Web technologies weren't originally designed to build robust applications in the browser. These frameworks attempt to enhance application performance and improve the developer and end-user experience until web standards catch up to modern use cases.
The virtual DOM (VDOM) is a programming concept where an ideal, or “virtual”, representation of a UI is kept in memory and synced with the “real” DOM by a library such as ReactDOM. This process is called reconciliation.
-
I think the answer that i'm looking for is Vartual DOM thanks for explaining to me– MuathNov 15, 2018 at 7:51
Your question is one of the difference between SPA (Single Page Applications) vs MPA (Multi-page Applications).
All of Vue, React and Angular use an SPA design to only update DOM elements that are changed, instead of reloading the entire page. This is the main problem that these frameworks aim to solve instead of using vanilla javascript.
-
javascript can update DOM elements too, i didn't get your answer clearly– MuathNov 14, 2018 at 21:57
-
correct, but its 10x easier and more readable to do it in an SPA Nov 14, 2018 at 22:03
The short answer to your question would be: because accessing the DOM elements is "expensive" (in terms of browser resources, memory, speed). That's why we have a Virtual DOM, a temporary copy of DOM which is purely in JS, and accessing, adding, modifying, and deleting elements is significantly faster, and that's why applications written in Angular, React or Vue has better performance.