Reputation: 1948
I have the following code:
span.appendChild(link);
span.appendChild(closeButton);
closeButton.appendChild(closeIcon);
What if I append closeIcon to closeButton before appending closeButton to span? Is there any difference? And is there any difference between cloned nodes inserted to DOM with js and the ones that are hardcoded in html?
Upvotes: 0
Views: 1086
Reputation: 13367
Normally the net effect should be the same (unless I misread). If the span is already in the DOM, and closeButton is not, you would get a slight performance improvement by appending to closeButton first (while it is not in the DOM) - this would avoid reflows.
Upvotes: 0
Reputation: 15351
The nodes will be added to the DOM in the order you define, however, their visual appearance may represent different ordering due to the elements' CSS properties.
Upvotes: 2