Mutation Observers in javascript?

Is this the way React/Vue etc do there "virtual DOM"? I'm trying to investigate them but it seems like they aren't really that well used outside of these frameworks?? If my assumption about is correct that is, and React does actually use them. Does anyone know of any tutorials etc on MuObs?

Start a personal dev blog on your domain for free and grow your readership.

3.4K+ developers have started their personal blogs on Hashnode in the last one month.

Write in Markdown 路 Publish articles on custom domain 路 Gain readership on day zero 路 Automatic GitHub backup and more

Comments (3)

j's photo

The virtual DOM is an observer concept yes :) and reactive systems use them. Check this out:

the first entry is the author of the virtual-dom :)

Hipkiss's photo

Can a vDOM just be as simple as a JSON of the whole DOM tree? Something like this:

[{
"tagName": "HTML",
"children": [{
"tagName": "HEAD",
"children": [
{"tagName":"TITLE"},
{"tagName":"STYLE"},
{"tagName":"SCRIPT"}
]
}]
}]

j's photo

in theory. yes :) But I didn't write it so I would look up the implementation :) it shouldn't be that complicated :)