createElement() vs createDocumentFragment()

I've been working on some #JavaScript to help populate pages with data returned from #AJAX requests. Generating #HTML elements or duplicating existing ones is pretty important for that sort of code. #Josh recommended checking out document fragments as they might be able to help. So I did. They can, but it depends what you're trying to do. In my case, it doesn't make much of a difference, as long as you put all the elements to be added into one container node before appending to the document. Otherwise, you could take a performance hit.

Check out this StackOverflow discussion for details on the differences.

#WebDevelopment

Posted 28 Mar 2019 by Brian