What’s the Deal with Display Contents vs. Display None for Live DOM Elements?

0
0
Asked By CuriousCoder42 On

Hey everyone! I'm working on a project using vanilla JavaScript and I'm trying to figure out the best way to manage live DOM elements. I've come across two approaches: using two sentinel elements to encapsulate my live collection, or using a single element with display contents so that the live collection becomes its children. I prefer the first method, but I'm noticing that it can be heavier on the DOM, and it seems like there are limits on the depth of the DOM that I need to consider. I'm curious if display contents is widely accepted these days, and what people think about encapsulating elements like this. Just to clarify, I'm not looking to use a virtual DOM for this specific use case!

1 Answer

Answered By TechieTommy On

If you're trying to keep track of live DOM elements, you might want to consider using MutationObservers. They can help monitor changes efficiently. However, it's worth noting that a virtual DOM can update the real one only when needed, which helps with performance—just something to think about!

Related Questions

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.