Skip to main content

Virtual Dom is not invented by react. It is part of HTML dom. It is lightweight and detached from the browser-specific implementation details.

We can think virtual DOM as React’s local and simplified copy of the HTML DOM. It allows React to do its computations within this abstract world and skip the “real” DOM operations, often slow and browser-specific. Actually there is no big differenc between DOM and VIRTUAL DOM.

Below are the points why Virtual Dom is used (source https://hackernoon.com/virtual-dom-in-reactjs-43a3fdb1d130Virtual DOM in ReactJS):

When you do:

document.getElementById('elementId').innerHTML = "New Value" Following thing happens:
  1. Browser needs to parse the HTML
  2. It removes the child element of elementId
  3. Updates the DOM value with new value
  4. Re-calculate the css for the parent and child
  5. Update the layout i.e. each elements exact co-ordinates on the screen
  6. Traverse the render tree and paint it on the browser display

Recalculating the CSS and changed layouts uses complex algorithm and they effect the performance.

As well as updating the DOM properties ie. values. It follows a algorithm.

Now, suppose if you update DOM 10 times directly, then all the above steps will run one by one and updating DOM algorithms will take time to updates DOM values.

This, is why Real DOM is slower than virtual DOM.

Virtual Dom is not invented by react. It is part of HTML dom. It is lightweight and detached from the browser-specific implementation details.

We can think virtual DOM as React’s local and simplified copy of the HTML DOM. It allows React to do its computations within this abstract world and skip the “real” DOM operations, often slow and browser-specific. Actually there is no big differenc between DOM and VIRTUAL DOM.

Below are the points why Virtual Dom is used (source https://hackernoon.com/virtual-dom-in-reactjs-43a3fdb1d130):

When you do:

document.getElementById('elementId').innerHTML = "New Value" Following thing happens:
  1. Browser needs to parse the HTML
  2. It removes the child element of elementId
  3. Updates the DOM value with new value
  4. Re-calculate the css for the parent and child
  5. Update the layout i.e. each elements exact co-ordinates on the screen
  6. Traverse the render tree and paint it on the browser display

Recalculating the CSS and changed layouts uses complex algorithm and they effect the performance.

As well as updating the DOM properties ie. values. It follows a algorithm.

Now, suppose if you update DOM 10 times directly, then all the above steps will run one by one and updating DOM algorithms will take time to updates DOM values.

This, is why Real DOM is slower than virtual DOM.

Virtual Dom is not invented by react. It is part of HTML dom. It is lightweight and detached from the browser-specific implementation details.

We can think virtual DOM as React’s local and simplified copy of the HTML DOM. It allows React to do its computations within this abstract world and skip the “real” DOM operations, often slow and browser-specific. Actually there is no big differenc between DOM and VIRTUAL DOM.

Below are the points why Virtual Dom is used (source Virtual DOM in ReactJS):

When you do:

document.getElementById('elementId').innerHTML = "New Value" Following thing happens:
  1. Browser needs to parse the HTML
  2. It removes the child element of elementId
  3. Updates the DOM value with new value
  4. Re-calculate the css for the parent and child
  5. Update the layout i.e. each elements exact co-ordinates on the screen
  6. Traverse the render tree and paint it on the browser display

Recalculating the CSS and changed layouts uses complex algorithm and they effect the performance.

As well as updating the DOM properties ie. values. It follows a algorithm.

Now, suppose if you update DOM 10 times directly, then all the above steps will run one by one and updating DOM algorithms will take time to updates DOM values.

This, is why Real DOM is slower than virtual DOM.

attribute source
Source Link
IanS
  • 16.3k
  • 9
  • 62
  • 85

Virtual Dom is not invented by react. It is part of HTML dom. It is lightweight and detached from the browser-specific implementation details.

We can think virtual DOM as React’s local and simplified copy of the HTML DOM. It allows React to do its computations within this abstract world and skip the “real” DOM operations, often slow and browser-specific. Actually there is no big differenc between DOM and VIRTUAL DOM.

Below are the points why Virtual Dom is used:

When you do:

document.getElementById('elementId').innerHTML = "New Value"

Following thing happens (source https://hackernoon.com/virtual-dom-in-reactjs-43a3fdb1d130):

  1. Browser needs to parse the HTML
  2. It removes the child element of elementId
  3. Updates the DOM value with new value
  4. Re-calculate the css for the parent and child
  5. Update the layout i.e. each elements exact co-ordinates on the screen
  6. Traverse the render tree and paint it on the browser display

When you do:

document.getElementById('elementId').innerHTML = "New Value" Following thing happens:
  1. Browser needs to parse the HTML
  2. It removes the child element of elementId
  3. Updates the DOM value with new value
  4. Re-calculate the css for the parent and child
  5. Update the layout i.e. each elements exact co-ordinates on the screen
  6. Traverse the render tree and paint it on the browser display

Recalculating the CSS and changed layouts uses complex algorithm and they effect the performance.

Recalculating the CSS and changed layouts uses complex algorithm and they effect the performance, asAs well as updating the DOM properties ie. values. It follows a algorithm.

Now, suppose if you update DOM 10 times directly, then all the above steps will run one by one and updating DOM algorithms will take time to updates DOM values.

This, is why Real DOM is slower than virtual DOM.

Virtual Dom is not invented by react. It is part of HTML dom. It is lightweight and detached from the browser-specific implementation details.

We can think virtual DOM as React’s local and simplified copy of the HTML DOM. It allows React to do its computations within this abstract world and skip the “real” DOM operations, often slow and browser-specific. Actually there is no big differenc between DOM and VIRTUAL DOM.

Below are the points why Virtual Dom is used:

When you do:

document.getElementById('elementId').innerHTML = "New Value"

Following thing happens:

  1. Browser needs to parse the HTML
  2. It removes the child element of elementId
  3. Updates the DOM value with new value
  4. Re-calculate the css for the parent and child
  5. Update the layout i.e. each elements exact co-ordinates on the screen
  6. Traverse the render tree and paint it on the browser display

Recalculating the CSS and changed layouts uses complex algorithm and they effect the performance, as well as updating the DOM properties ie. values. It follows a algorithm.

Now, suppose if you update DOM 10 times directly, then all the above steps will run one by one and updating DOM algorithms will take time to updates DOM values.

This, is why Real DOM is slower than virtual DOM.

Virtual Dom is not invented by react. It is part of HTML dom. It is lightweight and detached from the browser-specific implementation details.

We can think virtual DOM as React’s local and simplified copy of the HTML DOM. It allows React to do its computations within this abstract world and skip the “real” DOM operations, often slow and browser-specific. Actually there is no big differenc between DOM and VIRTUAL DOM.

Below are the points why Virtual Dom is used (source https://hackernoon.com/virtual-dom-in-reactjs-43a3fdb1d130):

When you do:

document.getElementById('elementId').innerHTML = "New Value" Following thing happens:
  1. Browser needs to parse the HTML
  2. It removes the child element of elementId
  3. Updates the DOM value with new value
  4. Re-calculate the css for the parent and child
  5. Update the layout i.e. each elements exact co-ordinates on the screen
  6. Traverse the render tree and paint it on the browser display

Recalculating the CSS and changed layouts uses complex algorithm and they effect the performance.

As well as updating the DOM properties ie. values. It follows a algorithm.

Now, suppose if you update DOM 10 times directly, then all the above steps will run one by one and updating DOM algorithms will take time to updates DOM values.

This, is why Real DOM is slower than virtual DOM.

Source Link

Virtual Dom is not invented by react. It is part of HTML dom. It is lightweight and detached from the browser-specific implementation details.

We can think virtual DOM as React’s local and simplified copy of the HTML DOM. It allows React to do its computations within this abstract world and skip the “real” DOM operations, often slow and browser-specific. Actually there is no big differenc between DOM and VIRTUAL DOM.

Below are the points why Virtual Dom is used:

When you do:

document.getElementById('elementId').innerHTML = "New Value"

Following thing happens:

  1. Browser needs to parse the HTML
  2. It removes the child element of elementId
  3. Updates the DOM value with new value
  4. Re-calculate the css for the parent and child
  5. Update the layout i.e. each elements exact co-ordinates on the screen
  6. Traverse the render tree and paint it on the browser display

Recalculating the CSS and changed layouts uses complex algorithm and they effect the performance, as well as updating the DOM properties ie. values. It follows a algorithm.

Now, suppose if you update DOM 10 times directly, then all the above steps will run one by one and updating DOM algorithms will take time to updates DOM values.

This, is why Real DOM is slower than virtual DOM.