{"action":"created","issue":{"url":"https://api.github.com/repos/mbostock/d3/issues/825","labels_url":"https://api.github.com/repos/mbostock/d3/issues/825/labels{/name}","comments_url":"https://api.github.com/repos/mbostock/d3/issues/825/comments","events_url":"https://api.github.com/repos/mbostock/d3/issues/825/events","html_url":"https://github.com/mbostock/d3/issues/825","id":7202473,"number":825,"title":"Create DOM element without appending it?","user":{"login":"zacwitte","id":270854,"avatar_url":"https://avatars.githubusercontent.com/u/270854?v=3","gravatar_id":"","url":"https://api.github.com/users/zacwitte","html_url":"https://github.com/zacwitte","followers_url":"https://api.github.com/users/zacwitte/followers","following_url":"https://api.github.com/users/zacwitte/following{/other_user}","gists_url":"https://api.github.com/users/zacwitte/gists{/gist_id}","starred_url":"https://api.github.com/users/zacwitte/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zacwitte/subscriptions","organizations_url":"https://api.github.com/users/zacwitte/orgs","repos_url":"https://api.github.com/users/zacwitte/repos","events_url":"https://api.github.com/users/zacwitte/events{/privacy}","received_events_url":"https://api.github.com/users/zacwitte/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":4,"created_at":"2012-09-28T01:33:18Z","updated_at":"2015-01-05T17:15:03Z","closed_at":"2012-10-01T15:22:59Z","body":"Is 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."},"comment":{"url":"https://api.github.com/repos/mbostock/d3/issues/comments/68740617","html_url":"https://github.com/mbostock/d3/issues/825#issuecomment-68740617","issue_url":"https://api.github.com/repos/mbostock/d3/issues/825","id":68740617,"user":{"login":"mbostock","id":230541,"avatar_url":"https://avatars.githubusercontent.com/u/230541?v=3","gravatar_id":"","url":"https://api.github.com/users/mbostock","html_url":"https://github.com/mbostock","followers_url":"https://api.github.com/users/mbostock/followers","following_url":"https://api.github.com/users/mbostock/following{/other_user}","gists_url":"https://api.github.com/users/mbostock/gists{/gist_id}","starred_url":"https://api.github.com/users/mbostock/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mbostock/subscriptions","organizations_url":"https://api.github.com/users/mbostock/orgs","repos_url":"https://api.github.com/users/mbostock/repos","events_url":"https://api.github.com/users/mbostock/events{/privacy}","received_events_url":"https://api.github.com/users/mbostock/received_events","type":"User","site_admin":false},"created_at":"2015-01-05T17:15:03Z","updated_at":"2015-01-05T17:15:03Z","body":"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:\r\n\r\n```js\r\nvar svg = d3.select(\"body\").append(\"svg\")\r\n    .remove()\r\n    .attr(\"width\", 400)\r\n    .attr(\"height\", 400);\r\n\r\nsvg.append(\"circle\")\r\n    .attr(\"r\", 200);\r\n\r\ndocument.body.appendChild(svg.node());\r\n```"}}