I need elegance and performance: how to decide by the "best implementation" for each DOM algorithm that I face. This simple "DOMNodeList grouper" illustrate many little dilemmas:

  • use iterator_to_array or "populate an array", when not all items need to be copied.
  • use clone operator, cloneNode method or import method?
  • use parentNode::method() or documentElement::method? (see here)
  • first removeChild or first replaceChild, no avoids "side effects"?
  • ...

My position, today, is only "do an arbitrary choice and follow it in all implementations" (like a "Convention over configuration" principle)... But, there are another considerations? About performance, there are some article showing benchmarks?

PS: this is a generic DOM question, any language (PHP, Javascript, Python, etc.) have the problem.

  • If your concerns are performance, the answer is always test it. And the answer could be different per every combination of language/library(/browser for JS) anyway. – Izkata Nov 3 '13 at 16:44
  • Yes, but my subquestion is "... there are some article showing benchmarks?". I also think that the majority of implementations are using LibXML2, so, will expect perfomance relations be ~"language independent". – Peter Krauss Nov 3 '13 at 17:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.