React prominently popularized the concept of a VDOM, abstracting away native DOM operations and instead rendering to a JS representation of the DOM. Then you can easily diff two states of your app and calculate the minimal DOM operations needed to transfer your old DOM into the new one.