Create DOM element without appending it?
See original GitHub issueIs it possible to create a DOM element without appending it? In building an SVG tree I want to create a <g>
element, add a bunch of children to it, then append the entire tree at once. I believe this is more efficient than calling append()
right after select().data().enter()
which would cause the browser to do more redraws than necessary.
Issue Analytics
- State:
- Created 11 years ago
- Comments:11 (3 by maintainers)
Top Results From Across the Web
creating element node without appending - Stack Overflow
createElement () creates an element owned by the document from which it is created but does not give it any position in the...
Read more >Document.createElement() - Web APIs | MDN
In an HTML document, the document.createElement() method creates the HTML element specified by tagName, or an HTMLUnknownElement if tagName ...
Read more >Creating, Deleting, and Moving Elements - Using D3.js
D3.js has a number of selection methods that add, remove, and reposition elements in the DOM. They include the following: selection.append(type) - create, ......
Read more >JavaScript HTML DOM Elements (Nodes) - W3Schools
To add a new element to the HTML DOM, you must create the element (element node) first, and then append it to an...
Read more >Data Binding to DOM in D3 - TutorialsTeacher
Learn how to bind data to DOM elements and create new elements based on your ... append() will create DOM elements for which...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
D3 5.0 added d3.create for creating a selection from a new detached DOM element. So you could say:
You haven’t set a width and height attribute on your svg element, and you haven’t specified the appropriate namespace in conjunction with document.createElementNS when creating the svg element. Another strategy you could consider is to remove the element from the DOM immediately after creating it: