Say we have 10,000 lines of code.We change 1 line of code and the browser DOM has to re render all 10,000 lines of code!
This is not true. Browsers only change the DOM tree at the place where you have requested that change. And this has nothing to do with the amount of lines of code of your application.
The reasoning behind VirtualDOM is that you may end up changing lots of parts of your DOM during a single iteration, so the browser would have to process all those changes independently. VirtualDOM framewokrs do keep track of these changes in their in-memory virtual dom and, when they know there are no more changes (the iteration has ended), they dump it all to the real DOM in a single change, and only around the areas where changes have occurred.
Is this faster? Arguably. If your screens do not have multiple changing parts that keep changing everytime (as in Facebook, for example), you can work without virtual doms and achieve pretty much the same speed with less memory consumption.
Okay.. Thanks a lot for this explanation. I will surely edit my blog. I apologize for the same. I have got a broader view on this concept. Thanks once again.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
This is not true. Browsers only change the DOM tree at the place where you have requested that change. And this has nothing to do with the amount of lines of code of your application.
The reasoning behind VirtualDOM is that you may end up changing lots of parts of your DOM during a single iteration, so the browser would have to process all those changes independently. VirtualDOM framewokrs do keep track of these changes in their in-memory virtual dom and, when they know there are no more changes (the iteration has ended), they dump it all to the real DOM in a single change, and only around the areas where changes have occurred.
Is this faster? Arguably. If your screens do not have multiple changing parts that keep changing everytime (as in Facebook, for example), you can work without virtual doms and achieve pretty much the same speed with less memory consumption.
Okay.. Thanks a lot for this explanation. I will surely edit my blog. I apologize for the same. I have got a broader view on this concept. Thanks once again.